Link to home
Start Free TrialLog in
Avatar of ionmanage
ionmanage

asked on

Scripting Help

Experts,

I am looking to modify the following script:

#include <windows.h>
#include <stdio.h>

#pragma comment(lib, "user32.lib")

void DumpDevice(const DISPLAY_DEVICE& dd, size_t nSpaceCount )
{
    printf("%*sDevice Name: %s\n", nSpaceCount, "", dd.DeviceName );
    printf("%*sDevice String: %s\n", nSpaceCount, "", dd.DeviceString );
    printf("%*sState Flags: %x\n", nSpaceCount, "", dd.StateFlags );
    printf("%*sDeviceID: %s\n", nSpaceCount, "", dd.DeviceID );
    printf("%*sDeviceKey: ...%s\n\n", nSpaceCount, "", dd.DeviceKey+42 );
}

int main()
{
    DISPLAY_DEVICE dd;

    dd.cb = sizeof(DISPLAY_DEVICE);

    DWORD deviceNum = 0;
    while( EnumDisplayDevices(NULL, deviceNum, &dd, 0) ){
        DumpDevice( dd, 0 );
        DISPLAY_DEVICE newdd = {0};
        newdd.cb = sizeof(DISPLAY_DEVICE);
        DWORD monitorNum = 0;
        while ( EnumDisplayDevices(dd.DeviceName, monitorNum, &newdd, 0))
        {
            DumpDevice( newdd, 4 );
            monitorNum++;
        }
        puts("");
        deviceNum++;
    }

    return 0;
}

Open in new window


The output of this code should display only the monitor information:

IE
\\.\DISPLAY1\Monitor0
\\.\DISPLAY1\Monitor1
\\.\DISPLAY1\Monitor2

I also need to know if the device is PnP or UPnp

Device Name: \\.\DISPLAY1\Monitor0
   Device String: Generic PnP Monitor
   State Flags: 3
   DeviceID: MONITOR\DEL4016\{4d36e96e-e325-11ce-bfc1-08002be10318}\0002
   DeviceKey: ...\Control\Class\{4d36e96e-e325-11ce-bfc1-08002be10318}\0002

Thanks in advance for you assistance with this.
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial