本帖最后由 afan 于 2013-10-31 15:37 编辑
回复 16# mikezunya
WinAPIEx.au3 这个头文件会由于升级而 增、删、改、重命名某(些)函数,所以会有此情况。
可以提取使用。$PID = ProcessExists("explorer.exe")
MsgBox(0, "", _WinAPI_GetModuleFileNameEx($PID))
Func _WinAPI_CloseHandle($hObject)
Local $aResult = DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hObject)
If @error Then Return SetError(@error, @extended, False)
Return $aResult[0]
EndFunc ;==>_WinAPI_CloseHandle
Func _WinAPI_GetCurrentProcessID()
Local $aResult = DllCall("kernel32.dll", "dword", "GetCurrentProcessId")
If @error Then Return SetError(@error, @extended, 0)
Return $aResult[0]
EndFunc ;==>_WinAPI_GetCurrentProcessID
Func _WinAPI_GetModuleFileNameEx($PID = 0)
If Not $PID Then
$PID = _WinAPI_GetCurrentProcessID()
If Not $PID Then
Return SetError(1, 0, 0)
EndIf
EndIf
Local $hProcess = DllCall('kernel32.dll', 'ptr', 'OpenProcess', 'dword', 0x00000410, 'int', 0, 'dword', $PID)
If (@error) Or (Not $hProcess[0]) Then
Return SetError(1, 0, '')
EndIf
Local $tPath = DllStructCreate('wchar[1024]')
Local $Ret = DllCall('psapi.dll', 'int', 'GetModuleFileNameExW', 'ptr', $hProcess[0], 'ptr', 0, 'ptr', DllStructGetPtr($tPath), 'int', 1024)
If (@error) Or (Not $Ret[0]) Then
$Ret = 0
EndIf
_WinAPI_CloseHandle($hProcess[0])
If Not IsArray($Ret) Then
Return SetError(1, 0, '')
EndIf
Return DllStructGetData($tPath, 1)
EndFunc ;==>_WinAPI_GetModuleFileNameEx
|