I’ve written a virtual display driver, and I’m using SwDeviceCreate to enumerate/create multiple instances. After each device is started (CM_NOTIFY_ACTION_DEVICEINSTANCESTARTED), Windows recognizes it and does something (based up cached info or lack thereof in the registry). Since I’m creating multiple instances, there’s considerable chaos as Windows encounters these new displays and potentially adds them to the desktop.
Enumerating/creating these devices seems to take considerably longer than just enabling a previously-created device in the disabled state. What I’d like to do is defer all of that “Windows desktop chaos” until I have all adapters created in a disabled state, then quickly enable them and set their display settings all at once.
I could call CM_Disable_DevNode
right after I see the Started notification, but I’ve seen timing issues previously where such calls sometimes fail silently.
I’m using SwDeviceCreate
to enumerate the devices, and Microsoft’s documentation is really minimal. You can pass in an array of DEVPROPERTIES
to set the device’s initial state, but looking through the DEVPKEY_Device_
* values, I don’t see anything obvious that would govern whether the device is initially disabled or enabled.
Can anyone offer suggestions, or point me to prior art? (Google for SwDeviceCreate, and you’ll pretty much hear crickets)