Created
January 2, 2014 09:19
-
-
Save kumatti1/8216755 to your computer and use it in GitHub Desktop.
DDC/CI確認
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define UNICODE | |
#include <HighLevelMonitorConfigurationAPI.h> | |
#include <Windows.h> | |
#include <stdio.h> | |
int CALLBACK WinMain( | |
_In_ HINSTANCE hInstance, | |
_In_ HINSTANCE hPrevInstance, | |
_In_ LPSTR lpCmdLine, | |
_In_ int nCmdShow | |
) | |
{ | |
HMONITOR hMonitor = NULL; | |
DWORD cPhysicalMonitors; | |
LPPHYSICAL_MONITOR pPhysicalMonitors = NULL; | |
// Get the monitor handle. | |
hMonitor = MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY); | |
// Get the number of physical monitors. | |
BOOL bSuccess = GetNumberOfPhysicalMonitorsFromHMONITOR( | |
hMonitor, | |
&cPhysicalMonitors | |
); | |
if (bSuccess) | |
{ | |
// Allocate the array of PHYSICAL_MONITOR structures. | |
pPhysicalMonitors = (LPPHYSICAL_MONITOR) malloc( | |
cPhysicalMonitors* sizeof(PHYSICAL_MONITOR)); | |
if (pPhysicalMonitors != NULL) | |
{ | |
// Get the array. | |
bSuccess = GetPhysicalMonitorsFromHMONITOR( | |
hMonitor, cPhysicalMonitors, pPhysicalMonitors); | |
// Use the monitor handles (not shown). | |
//輝度取得 | |
DWORD dwMin, dwCurrent, dwMax; | |
BOOL bRet = GetMonitorBrightness(pPhysicalMonitors->hPhysicalMonitor, | |
&dwMin, | |
&dwCurrent, | |
&dwMax); | |
char szTmp[50]; | |
sprintf(szTmp, "%d\n%d\n%d\n", dwMin, dwCurrent, dwMax); | |
MessageBoxA(nullptr, szTmp, "輝度取得", MB_OK); | |
sprintf(szTmp, "%d\n", bRet); | |
MessageBoxA(nullptr, szTmp, "輝度取得成否", MB_OK); | |
DWORD dw2, dw3; | |
bRet = GetMonitorCapabilities(pPhysicalMonitors->hPhysicalMonitor, | |
&dw2, &dw3); | |
sprintf(szTmp, "%d\n%d\n%d\n", dw2, dw3, bRet); | |
MessageBoxA(nullptr, szTmp, "輝度取得可否", MB_OK); | |
// DWORD dwNewBrightness = 0; | |
// SetMonitorBrightness(pPhysicalMonitors->hPhysicalMonitor, | |
// dwNewBrightness); | |
// Close the monitor handles. | |
bSuccess = DestroyPhysicalMonitors( | |
cPhysicalMonitors, | |
pPhysicalMonitors); | |
// Free the array. | |
free(pPhysicalMonitors); | |
} | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment