I want to get the pixels of every physical screen individually, but MSDN says GetDC
needs a window to know which screen to get the handle of. Is there any way of telling it which handle to use without using a window or mouse?
So I can call EnumDisplayDevices
and as suggested loop through to find how many monitors are attached and the information of each: Problem is I am using the code provided by Microsoft:
http://msdn.microsoft.com/en-us/library/windows/desktop/dd144942(v=vs.85).aspx
Using this code it has errors on the EnumDisplayDevices
call "Too many arguments in function call"
BOOL GetDisplayMonitorInfo(int nDeviceIndex, LPSTR lpszMonitorInfo)
{
FARPROC EnumDisplayDevices;
HINSTANCE hInstUser32;
DISPLAY_DEVICE DispDev;
char szSaveDeviceName[33];
BOOL bRet = TRUE;
HRESULT hr;
hInstUser32 = LoadLibrary("c:\\windows\User32.DLL");
if (!hInstUser32) return FALSE;
EnumDisplayDevices = (FARPROC)GetProcAddress(hInstUser32, "EnumDisplayDevicesA");
if (!EnumDisplayDevices) {
FreeLibrary(hInstUser32);
return FALSE;
}
ZeroMemory(&DispDev, sizeof(DispDev));
DispDev.cb = sizeof(DispDev);
if (EnumDisplayDevices(NULL, nDeviceIndex, &DispDev, 0))
{
hr = StringCchCopy(szSaveDeviceName, 33, DispDev.DeviceName);
if (FAILED(hr))
{
}
EnumDisplayDevices(szSaveDeviceName, 0, &DispDev, 0);
hr = StringCchCopy(lpszMonitorInfo, 129, DispDev.DeviceString);
if (FAILED(hr))
{
// TODO: write error handler
}
}
else {
bRet = FALSE;
}
FreeLibrary(hInstUser32);
return bRet;
}