Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The code example in this topic shows you how to obtain a volume GUID path for each local volume associated with a drive letter that is currently in use on the computer.
The code example uses the GetVolumeNameForVolumeMountPoint function.
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#define BUFSIZE MAX_PATH
void main(void)
{
BOOL bFlag;
TCHAR Buf[BUFSIZE]; // temporary buffer for volume name
TCHAR Drive[] = TEXT("c:\\"); // template drive specifier
TCHAR I; // generic loop counter
// Walk through legal drive letters, skipping floppies.
for (I = TEXT('c'); I < TEXT('z'); I++ )
{
// Stamp the drive for the appropriate letter.
Drive[0] = I;
bFlag = GetVolumeNameForVolumeMountPoint(
Drive, // input volume mount point or directory
Buf, // output volume name buffer
BUFSIZE ); // size of volume name buffer
if (bFlag)
{
_tprintf (TEXT("The ID of drive \"%s\" is \"%s\"\n"), Drive, Buf);
}
}
}
For an example that enumerates all locally attached volumes and displays the device path, volume GUID path, and mounted paths (including drive letters), see Displaying Volume Paths.
Events
Apr 8, 3 PM - May 28, 7 AM
Sharpen your AI skills and enter the sweepstakes to win a free Certification exam
Register now!