Sign in to follow this  
Followers 0
gretty

DBT_DEVICEARRIVAL Message is sending unrecognisable Class GUIDs

3 posts in this topic

Hello

 

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!!!

 

0

Share this post


Link to post
Share on other sites
Your isMonitorDevice() function is simply checking against a single specific GUID (based on what I saw on stackoverflow). Isn't it possible that there's more than one device class for monitors? (It's also possible that this section of the API is broken. A couple things found while poking around google suggest that this may be the case.)

What is your end goal? What are you using the GUIDs for? Edited by Khatharr
0

Share this post


Link to post
Share on other sites
The goal is to detect when a tv is connected to the computer. So I check the class guid of a newly connected device and compare it to the generic monitor guid. Maybe there's an easier way though, any ideas?
0

Share this post


Link to post
Share on other sites
Are you using DirectX? I think you could you just respond to the DBT_DEVICEARRIVAL message by re-enumerating the displays. Edited by Khatharr
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0