_GetFullPath
Publicado: 02 Jun 2014, 23:10
Necesitaba encontrar la ruta completa de un archivo sabiendo solo el nombre del proceso y salio esto basándome en el codigo en C de Emerick Rogul.
Saludos
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.8.1
Author: Naker90
Script Function:
Obtiene la ruta completa de un proceso en ejecucion
Basado en el codigo en C de Emerick Rogul
http://stackoverflow.com/questions/1933113/c-windows-how-to-get-process-path-from-its-pid
#ce ----------------------------------------------------------------------------
Func _GetFullPath($sProcessName)
Const $sPROCESS_QUERY_INFORMATION = 0x0400
Const $sPROCESS_VM_READ = 0x0010
Const $sMAX_PATH = 500
Local $sPID = ProcessExists($sProcessName)
if $sPID = 0 then
MsgBox(16, 'ERROR', 'El Proceso expecificado no esta en ejecución')
Exit
EndIf
Local $sHandle = DllCall('Kernel32.dll','Ptr', 'OpenProcess','int', BitOR($sPROCESS_QUERY_INFORMATION, $sPROCESS_VM_READ), 'int', 0, 'int', $sPID)
Local $sFileStruct = DllStructCreate('Wchar[' & $sMAX_PATH & ']')
Local $sGetModuleFileNameExW = DllCall('Psapi.dll', 'Dword', 'GetModuleFileNameExW', 'Ptr', $sHandle[0], 'Ptr', 0, 'Ptr', DllStructGetPtr($sFileStruct), 'Dword', $sMAX_PATH)
DllCall('Kernel32.dll','int', 'CloseHandle','Ptr', $sHandle[0])
Local $sReturn = DllStructGetData($sFileStruct, 1)
Return $sReturn
EndFunc
Ejemplo:
Código: Seleccionar todo
Llamada: _GetFullPath('Anotador Naker90.exe')
Retorna: C:\Users\Naker90\Desktop\Anotador Naker90.exe