Hello,
I am trying to get the DISPLAY_DEVICE structure of a multi-display Windows system.
In my test system, the function returns TRUE up to the 4th device (DevNum = 4) and then is FALSE for higher values, as expected by the function description:
link text
Here is the code:
Dim DevNum As UInt32
Dim mbDisplayDevice As MemoryBlock
Soft Declare Function EnumDisplayDevices Lib "user32" Alias "EnumDisplayDevicesA" (lpDevice As Ptr, iDevNum As UInt32, lpDisplayDevice As Ptr, dwFlags As UInt32) As Boolean
DevNum = 0
mbDisplayDevice = New MemoryBlock(424) // = 4 + 32 + 128 + 4 + 128 + 128
While EnumDisplayDevices(nil, DevNum, mbDisplayDevice, 0)
// when TRUE, look within mbDisplayDevice but always filled with zeros!
DevNum = DevNum + 1
Wend
The output data should be available in the lpDisplayDevice MemoryBlock but this block is always filled with zeros (I looked at each iteration of DevNum!).
It should be formatted with the following structure (from Microsoft):
typedef struct _DISPLAY_DEVICE {
DWORD cb;
TCHAR DeviceName[32];
TCHAR DeviceString[128];
DWORD StateFlags;
TCHAR DeviceID[128];
TCHAR DeviceKey[128];
} DISPLAY_DEVICE, *PDISPLAY_DEVICE;
According to the function doc, the first function call is done with lpDevice = nil and the other calls (not shown in the code above) should be done with the proper lpDevice string found from the nil call. Since the MemoryBlock is filled with zeros, I cannot go deeper.
Thanks in advance for any help!