检索指定装入点的卷 GUID 路径.
#Include <WinAPIEx.au3>
_WinAPI_GetVolumeNameForVolumeMountPoint ( $sPath )
$sPath | 安装文件夹的路径(例如, Y:\MountX\) 或驱动器名 (例如, X:\) |
成功: | 返回卷的 GUID 路径. |
路径形式为 "\\?\Volume{GUID}\",其中的 GUID 是 GUID 卷的标识. | |
如果有一个以上的卷 GUID 路径,仅返回装入管理缓存中的第一个卷 GUID 路径. | |
失败: | 返回空字符串,设置 @error 标志为非 0 值. |
在MSDN中搜索
#Include <WinAPIEx.au3>
Opt('MustDeclareVars', 1)
Global $sPath = @ScriptDir & '\Mount'
Global $GUID, $Count = 0
While FileExists($sPath & $Count)
$Count += 1
WEnd
$sPath &= $Count & '\'
If Not DirCreate($sPath) Then
MsgBox(16, 'Error', 'Unable to create folder.')
Exit
EndIf
$GUID = _WinAPI_GetVolumeNameForVolumeMountPoint(@HomeDrive & '\')
If _WinAPI_SetVolumeMountPoint($sPath, $GUID) Then
MsgBox(64, '', 'The drive "' & StringUpper(@HomeDrive) & '" has been associated with "' & $sPath & '".' & @CR & @CR & 'Press OK to unmount folder.')
_WinAPI_DeleteVolumeMountPoint($sPath)
Else
MsgBox(16, 'Error', 'Unable to mount folder.')
EndIf
DirRemove($sPath)