本帖最后由 Qokelate 于 2012-5-4 13:52 编辑
现成的Au3里面找不到相关函数,只好自己弄个用着先,不过有个问题搞不懂,请教达人
缓冲区大小如何自动获取? (cchBufferLength)
Func OpenKernel32DLL($CloseHWND = 0)
If $CloseHWND = 0 Then Return DllOpen('Kernel32.dll')
DllClose($CloseHWND)
EndFunc ;==>OpenKernel32DLL
;~ HANDLE WINAPI FindFirstVolume(
;~ __out LPTSTR lpszVolumeName,
;~ __in DWORD cchBufferLength
;~ );
Func FindFirstVolume()
Local $hDLL = OpenKernel32DLL()
Local $tAPI = DllStructCreate('char VolumeName[255]')
Local $p1 = DllStructGetPtr($tAPI, 1)
Local $iLen = DllStructGetSize($tAPI)
Local $API = DllCall($hDLL, 'Handle', 'FindFirstVolume', 'ptr', $p1, 'dword', $iLen)
OpenKernel32DLL($hDLL)
Return $API[0]
EndFunc ;==>FindFirstVolume
;~ BOOL WINAPI FindVolumeClose(
;~ __in HANDLE hFindVolume
;~ );
Func FindVolumeClose($hVolume)
Local $hDLL = OpenKernel32DLL()
DllCall($hDLL, 'int', 'FindVolumeClose', 'handle', $hVolume)
OpenKernel32DLL($hDLL)
EndFunc ;==>FindVolumeClose
;~ BOOL WINAPI FindNextVolume(
;~ __in HANDLE hFindVolume,
;~ __out LPTSTR lpszVolumeName,
;~ __in DWORD cchBufferLength
;~ );
Func FindNextVolume($hVolume)
Local $tAPI = DllStructCreate('char VolumeName[255]')
Local $p1 = DllStructGetPtr($tAPI, 1)
Local $iLen = DllStructGetSize($tAPI)
Local $hDLL = OpenKernel32DLL()
Local $API = DllCall($hDLL, 'int', 'FindNextVolume', 'handle', $hVolume, 'ptr', $p1, 'dword', $iLen)
OpenKernel32DLL($hDLL)
Return DllStructGetData($tAPI, 1)
EndFunc ;==>FindNextVolume
Local $hFind = FindFirstVolume()
Local $sVolumeMP
While 1
$sVolumeMP = FindNextVolume($hFind)
If $sVolumeMP = '' Then ExitLoop
MsgBox(0,0,$sVolumeMP)
WEnd
FindVolumeClose($hFind)
|