I using EnumDisplayDevices that give me obtain information about the display devices in the current session.
But i need information about the display devices regardless of session. Because i create some windows service application (System process).
Does anybody know some alternative for this code:
vncDesktop::GetNrMonitors()
{
if(OSversion()==3 || OSversion()==5) return 1;
int i;
int j=0;
helper::DynamicFn<pEnumDisplayDevices> pd("USER32","EnumDisplayDevicesA"); // it's EnumDisplayDevices function
if (pd.isValid())
{
DISPLAY_DEVICE dd;
ZeroMemory(&dd, sizeof(dd));
dd.cb = sizeof(dd);
for (i=0; (*pd)(NULL, i, &dd, 0); i++)
{
if (dd.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)
if (!(dd.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER))j++;
}
}
return j;
}
Thanks in advance!
I found solution for this issue. Only need create process user – System and SessionID – some user. And then all working fine.