Last active
January 4, 2016 01:49
-
-
Save kumatti1/8550694 to your computer and use it in GitHub Desktop.
IntelのCOM
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
#import "igfxsrvc.exe" | |
#include <windows.h> | |
#include <stdio.h> | |
using namespace IGFXSRVCLib; | |
void _SetBrightness() | |
{ | |
try { | |
DWORD dwDevice = 1; | |
//DISPLAY_DEVICEW DisplayDevice; | |
//BOOL bRet = EnumDisplayDevicesW(nullptr, dwDevice, &DisplayDevice, 0); | |
//if (!bRet) return; | |
IColorPtr pUnk; | |
HRESULT hr = pUnk.CreateInstance(__uuidof(Color)); | |
if (FAILED(hr)) _com_issue_error(hr); | |
long Supported = pUnk->IsSupported(dwDevice); | |
char tmp[50]; | |
sprintf(tmp, "%d", Supported); | |
MessageBoxA(nullptr, tmp, "test", MB_OK); | |
//明度取得 | |
//0は全色と思われる | |
long pVal = pUnk->GetMainScreenBrightness(dwDevice, 0); | |
sprintf(tmp, "%d", pVal); | |
MessageBoxA(nullptr, tmp, "test", MB_OK); | |
int a, b, c, d, e; | |
pUnk->GetColorDefault(&a, &b, &c, &d, &e); | |
sprintf(tmp, "%d\n%x\n%x\n%x\n%x\n", a, b, c, d, e); | |
MessageBoxA(nullptr, tmp, "test", MB_OK); | |
} | |
catch (_com_error& e) { | |
MessageBoxA(nullptr, e.ErrorMessage(), "err", MB_OK); | |
} | |
} | |
int CALLBACK WinMain( | |
_In_ HINSTANCE hInstance, | |
_In_ HINSTANCE hPrevInstance, | |
_In_ LPSTR lpCmdLine, | |
_In_ int nCmdShow | |
) | |
{ | |
::CoInitialize(NULL); | |
_SetBrightness(); | |
::CoUninitialize(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment