I've been trying to watch a USB subsystem to detect when devices are added or removed, but I'm having trouble decoding the PDEV_BROADCAST_DEVICEINTERFACE::dbcc_name
field. My code is based on an example over on codeproject.
If I right-click in my C++/CLI application in visual studio and go to the declaration in Dbt.h
I get:
typedef struct _DEV_BROADCAST_DEVICEINTERFACE_W {
DWORD dbcc_size;
DWORD dbcc_devicetype;
DWORD dbcc_reserved;
GUID dbcc_classguid;
wchar_t dbcc_name[1];
} DEV_BROADCAST_DEVICEINTERFACE_W, *PDEV_BROADCAST_DEVICEINTERFACE_W;
Which suggests that the name should be a wchar_t
. Feeding this into a new System::String just comes up with random characters. Is there more to converting a wchar_t string?
[edit] Essentially I want to do this in C++-cli but how do I port that?