sazr
sazr

Reputation: 25928

DBT_DEVICEARRIVAL Message is sending unrecognisable Class GUIDs

I am attempting to determine the Class Type of a device that has been connected to the computer. If its a Monitor(for eg a TV or Projector) I want to perform specific actions like change the display settings of the computer.

My method of determining the class type of a device involves the following steps:

  • Register for device notifications
  • Detect WM_DEVICECHANGE events: if the wParam value = DBT_DEVICEARRIVAL:
    • I convert the lParam value to a PDEV_BROADCAST_DEVICEINTERFACE variable and inspect that variables dbcc_classguid attribute
    • If the dbcc_classguid attribute == "{4d36e96e-e325-11ce-bfc1-08002be10318}" then I have found a monitor device

My Problem: Whenever I connect my LG Wide Screen TV to my computer it sends an unrecognisable dbcc_classguid.

For some reason, upon connection of the TV I receive 2 DBT_DEVICEARRIVAL messages. The lParam contains the following GUID's. What kind of device class is this?:

{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}
{866519b5-3f07-4c97-b7df-24c5d8a8ccb8}

Funnily enough if I inspect the Windows Device Manager application(after I have connected the TV) I can see that the TV is stored under Monitors and that its class GUID is indeed the Monitor Class GUID, ie, {4d36e96e-e325-11ce-bfc1-08002be10318}. So this is REALLY weird. Also I connected a regular computer monitor screen to my laptop and it sent the exact same GUIDs and also sent 2 arrival messages.

Heres my code. Why am I receiving weird Class GUIDs upon connection of a TV to my computer? What kind of device are those 2 GUID's for? Maybe I am receiving the Hardware GUIDs and not the Class GUIDs?

    case DBT_DEVICEARRIVAL:
    {
        PDEV_BROADCAST_HDR pBroad = (PDEV_BROADCAST_HDR) lParam;
        if (pBroad->dbch_devicetype != DBT_DEVTYP_DEVICEINTERFACE) {
            debug_print("pBroad->dbch_devicetype != DBT_DEVTYP_DEVICEINTERFACE\n");
            break;
        }

        PDEV_BROADCAST_DEVICEINTERFACE pInter = (PDEV_BROADCAST_DEVICEINTERFACE) pBroad;
        _tprintf(_T("Device Data: %s\n %x\n\n"), pInter->dbcc_name, pInter->dbcc_devicetype);

        debug_print("Printing Device Data");
        outputDeviceData(toString(pInter->dbcc_classguid), SPDRP_CLASSGUID);

        if (isMonitorDevice(pInter->dbcc_classguid)) {
            // TODO: change display mode and etc.
            debug_print("is MonitorDevice!!!");
        }
        else debug_print("is NOT MonitorDevice!!!");
    }
    break;

The output of my application is:

Message DBT_DEVICEARRIVAL:

Device Data: \?\DISPLAY#GSM3AD7#5&20a3f50d&0&UID513#{866519b5-3f07-4c97-b7df-24 c5d8a8ccb8} 5

{866519b5-3f07-4c97-b7df-24c5d8a8ccb8} is NOT MonitorDevice!!!

Message DBT_DEVICEARRIVAL:

Device Data: \?\DISPLAY#GSM3AD7#5&20a3f50d&0&UID513#{e6f07b5f-ee97-4a90-b076-33 f57bf4eaa7} 5

{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7} is NOT MonitorDevice!!!

Upvotes: 2

Views: 989

Answers (1)

Hans Passant
Hans Passant

Reputation: 941635

{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7} is GUID_DEVINTERFACE_MONITOR

MSDN page is here. Something must be wrong with your isMonitorDevice() function, I can't see it from here. Use IsEqualGUID() to compare guid values.

Upvotes: 1

Related Questions