Last active
August 29, 2015 14:04
-
-
Save kumatti1/acf3421cb60f361fd823 to your computer and use it in GitHub Desktop.
COM版SetColor
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 | |
#import "igfxsrvc.exe" | |
#include <windows.h> | |
#include <stdio.h> | |
#include <comdef.h> | |
using namespace IGFXSRVCLib; | |
void GetName() | |
{ | |
try { | |
IEDIDPtr pED; | |
HRESULT hr = pED.CreateInstance(__uuidof(EDID)); | |
if (FAILED(hr)) _com_issue_error(hr); | |
DWORD dwDevice = 0; | |
for(int i =0;i<32;i++) | |
{ | |
try { | |
dwDevice = 1<<i; | |
_bstr_t bstr; | |
hr = pED->GetSerialNumber(dwDevice, bstr.GetAddress() ); | |
if(hr==S_OK) break; | |
} | |
catch (_com_error& err) { | |
//if(err.Error() == E_FAIL ) | |
} | |
} | |
IColorPtr pColor; | |
hr = pColor.CreateInstance(__uuidof(Color)); | |
if (FAILED(hr)) _com_issue_error(hr); | |
BYTE pByte[60]; | |
pColor->GetColor(dwDevice, 60, pByte); | |
if (FAILED(hr)) _com_issue_error(hr); | |
long value=0; | |
pColor->get_MainScreenBrightness(dwDevice, 3, &value); | |
if (FAILED(hr)) _com_issue_error(hr); | |
char tmp[50]; | |
sprintf(tmp,"%x", value); | |
MessageBoxA(0,tmp, "", 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); | |
GetName(); | |
::CoUninitialize(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment