If I have a path on a drive, how do I retrieve that drive's GUID number?
I need it to read this key:
HK_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\Volume
If I have a path on a drive, how do I retrieve that drive's GUID number?
I need it to read this key:
HK_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BitBucket\Volume
You can use the winapi GetVolumeNameForVolumeMountPoint
function to retrieve the GUID for the volume that has that drive letter.
#include "stdafx.h"
#include <windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
TCHAR volumeName[MAX_PATH + 1] = { 0 };
GetVolumeNameForVolumeMountPoint("C:\\", volumeName, MAX_PATH);
_tprintf(_T("VolumeName: %s\n"), volumeName);
}
Here is the output:
VolumeName: \\?\Volume{f3b89248-8457-1ae3-9f8c-806e6f6b6923}\
From here you can use a substring or regex to cut out the part that contains the GUID.