Jump to content
Sign in to follow this  

Detecting hardware connected then run program with parameters

Recommended Posts

Hey guys.

Ive got this laptop which has an intel gpu and a nvidia gpu which I switch around depending on what I need..

I overclock this nvidia gpu but problem is that these clocks disappear when I switch away from it.

Therefore I need a way to detect the GPU being "inserted" (it doesn't appear in device manager before it's in use)

I found something with WM_DEVICECHANGE in my googling and thru a script I got this info, which should be what happens when its toggled:

WM_DEVICECHANGE Message 537 arrived:
WPARAM: 0x8000
LPARAM: 0x1af588
   dbch_size = 238, dbch_devicetype = 0x5
   dbcc_classguid = 5b45201d-f2f2-4f3b-85bb-30ff1f953599
   dbcc_name = \\?\PCI#VEN_10DE&DEV_0A2B&SUBSYS_905A104D&REV_A2#4&4cefabd&0&0008#{5b45201d-f2f2-4f3b-85bb-30ff1f953599}
Device 1 - DevInfoData Size 28 - Device Setup Class GUID 4d36e968-e325-11ce-bfc1-08002be10318 - 2648
   Name: \\?\pci#ven_10de&dev_0a2b&subsys_905a104d&rev_a2#4&4cefabd&0&0008#{5b45201d-f2f2-4f3b-85bb-30ff1f953599}
   Device Instance Id:    PCI\VEN_10DE&DEV_0A2B&SUBSYS_905A104D&REV_A2\4&4CEFABD&0&0008
   SPDRP_FRIENDLYNAME:    Not Found, Ret 0 ErrorLevel 0 13 The data is invalid. 
   SPDRP_MFG:             NVIDIA
   SPDRP_CLASS:           Display
   SPDRP_SERVICE:         nvlddmkm
   SPDRP_LOCATION_INFORMATION: PCI bus 1, device 0, function 0

Now I just need somehow to have a script that notices just this, then basically launches an exe twice, each with different overclock parameters.

I've seen some scripts that should do this with USBs being inserted but I simply cannot find anything that my noobness can figure out, so I was hoping some clever guy in here could help?



Share this post

Link to post
Share on other sites


I don't have the HW to check, just as a start: Device Manager (reflecting various keys/vals in the Registry) can display all known, even not present devices:

  • open a CMD box
  • set devmgr_show_non_present_devices=1
  • start devmgmt.msc (from within this CMD box!)
  • in device manager, main menu, 3rd entry (maybe "views" in English) --> something like "show hidden devices"


That might give you a start to check, what's the difference in Registy / WMI status depending on what GPU is the "inserted" one.

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

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  

  • Create New...