Function Reference


_WinAPI_GetVolumeNameForVolumeMountPoint

Retrieves a volume GUID path for the volume that is associated with the specified volume mount point

#include <WinAPIFiles.au3>
_WinAPI_GetVolumeNameForVolumeMountPoint ( $sMountedPath )

Parameters

$sMountedPath The path of a mounted folder (for example, Y:\MountX\) or a drive letter (for example, X:\).

Return Value

Success: The volume GUID path. This path is of the form "\\?\Volume{GUID}\" where GUID is a GUID that
identifies the volume. If there is more than one volume GUID path for the volume, only the first one
in the mount manager's cache is returned.
Failure: Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information.

See Also

Search GetVolumeNameForVolumeMountPoint in MSDN Library.

Example

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>

Local $sPath = @TempDir & '\Mount'
Local $iCount = 0

While FileExists($sPath & $iCount)
        $iCount += 1
WEnd

$sPath &= $iCount & '\'

If Not DirCreate($sPath) Then
        MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', 'Unable to create folder.')
        Exit
EndIf

Local $sGUID = _WinAPI_GetVolumeNameForVolumeMountPoint(@HomeDrive & '\')
If _WinAPI_SetVolumeMountPoint($sPath, $sGUID) Then
        MsgBox(($MB_ICONINFORMATION + $MB_SYSTEMMODAL), '', 'The drive "' & StringUpper(@HomeDrive) & '" has been associated with "' & $sPath & '".' & @CRLF & @CRLF & 'Press OK to unmount folder.')
        _WinAPI_DeleteVolumeMountPoint($sPath)
Else
        MsgBox(($MB_ICONERROR + $MB_SYSTEMMODAL), 'Error', 'Unable to mount folder.')
EndIf

DirRemove($sPath)