Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to get Path from device GUID?

606 views
Skip to first unread message

szyk...@gmail.com

unread,
Aug 18, 2017, 4:28:55 AM8/18/17
to
Hi
I searched web half day yesterday without success. So I am asking there - maybe you know how to do this.

I want to find all mobile device paths (mounted directories with files). Called in Windows: directories without mounting.

I get device GUID by RegisterDeviceNotification function, and I successfully get
WM_DEVICECHANGE message with
lParam->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE.
Then I cast lParam:
PDEV_BROADCAST_DEVICEINTERFACE lDevice = (PDEV_BROADCAST_DEVICEINTERFACE) lParam;
And finally got:
lDevice->dbcc_name
which contains GUID.

Now when I have Guid I imagine that I can get (some how) directories which belong to it. But I don't konw how to do it. Please help me.

thanks and best regards
Szyk Cech

Uwe Sieber

unread,
Aug 18, 2017, 5:23:51 AM8/18/17
to

What kind of device are you talking about, storage volumes?

dbcc_name contains the device's "device path", like
\\?\storage#volume#{a55a6996-f2f3-11e4-a33e-8f009a75583a}#0000000000010000#{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}
The first GUID random, the second is the device interface
GUID (GUID_DEVINTERFACE_VOLUME for a storage volume).

With a storage volume's device path you can call
GetVolumeNameForVolumeMountPoint which gives you
the "volume name" like
\\?\Volume{a55a6998-f2f3-11e4-a33e-8f009a75583a}\

With the volume name you can call GetVolumePathNamesForVolumeName
to get all its mount points (drive letter and NTFS folders
which the volume is mounted to).
I guess that is what you want.


Uwe

szyk...@gmail.com

unread,
Aug 18, 2017, 6:58:34 AM8/18/17
to
> What kind of device are you talking about, storage volumes?

Sorry, I miss that.
I want to get portable devices directories (mean: mobile phones and tablets).
From notification message I get:
\\\\?\\USB#VID_12D1&PID_256B#7SZ5S8UGSGA695GQ#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
I assume that {a5dcbf10-6530-11d2-901f-00c04fb951ed} is GUID of the mobile.
It appears in Windows as: "This computer\Y360-U61" - I want to get this directory from WinApi.

> With a storage volume's device path you can call
I haven't any "device path" just above string with GUID... Or maybe there is other way around..

szyk...@gmail.com

unread,
Aug 18, 2017, 6:59:30 AM8/18/17
to
> I want to get portable devices directories (mean: mobile phones and tablets).

Of course plugged via USB.

Uwe Sieber

unread,
Aug 18, 2017, 9:02:52 AM8/18/17
to
A device path ends with a device interface GUID. {a5dcbf10-6530-11d2-901f-00c04fb951ed}
is GUID_DEVINTERFACE_USB_DEVICE. Every USB device's device path ends with it.

I assume that this USB device has a child device which is what you are looking for.
UsbTreeView can show: http://www.uwe-sieber.de/usbtreeview_e.html

Sorry, I have no knowledge about WPD or MTP devices. Maybe there is a WMI interface.


Uwe



0 new messages