Mikon Posted August 10, 2005 Share Posted August 10, 2005 here is my code Func ProcessGetFileName($PId) Local $PROCESS_ALL_ACCESS = 0x1F0FFF Local $P_HANDLE = DllCall("kernel32.dll", "int", "OpenProcess", "int", $PROCESS_ALL_ACCESS, "int", 0, "int", $PId) Local $Buffer Local $Check = DllCall("psapi.dll", "int", "GetProcessImageFileName", "int", $P_HANDLE[0], "str", $Buffer, "int", 4095);this is the line with the error DllCall("kernel32.dll", "int", "CloseHandle", "int", $P_HANDLE[0]) If $Check[0] Then Return $Buffer Return "" EndFunc i commented the line, where the problem is i hope you can help me with this thanks, Mikon Link to comment Share on other sites More sharing options...
w0uter Posted August 10, 2005 Share Posted August 10, 2005 use DllStruct. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
Valik Posted August 10, 2005 Share Posted August 10, 2005 use DllStruct.<{POST_SNAPBACK}>Wrong answer! Here's why.here is my codeFunc ProcessGetFileName($PId) Local $PROCESS_ALL_ACCESS = 0x1F0FFF Local $P_HANDLE = DllCall("kernel32.dll", "int", "OpenProcess", "int", $PROCESS_ALL_ACCESS, "int", 0, "int", $PId) Local $Buffer Local $Check = DllCall("psapi.dll", "int", "GetProcessImageFileName", "int", $P_HANDLE[0], "str", $Buffer, "int", 4095);this is the line with the error DllCall("kernel32.dll", "int", "CloseHandle", "int", $P_HANDLE[0]) If $Check[0] Then Return $Buffer Return "" EndFunci commented the line, where the problem isi hope you can help me with thisthanks, Mikon<{POST_SNAPBACK}>Quite simply, this is a RTFM opportunity. The variable $Buffer is not modified itself (Its not even needed). Instead (as the documentation points out), any variables which are changed by the function can be found in the array that is returned. So the information you seek is located in $Check[2], not in $Buffer (Which you don't need, as I mentioned).Here is the correct code. I had to changed 3 things. First, the correct version of PSAPI.dll was not being found so I explicitly qualified it with a path. Second, because of the first, the script was crashing. I added in code to save @error and check it later on so you won't access an invalid array element if the DllCall() failed. I also removed $Buffer.Func ProcessGetFileName($PId) Local $PROCESS_ALL_ACCESS = 0x1F0FFF Local $P_HANDLE = DllCall("kernel32.dll", "int", "OpenProcess", "int", $PROCESS_ALL_ACCESS, "int", 0, "int", $PId) Local $Check = DllCall(@SystemDir & "\psapi.dll", "int", "GetProcessImageFileName", "int", $P_HANDLE[0], "str", "", "int", 4095);this is the line with the error Local $error = @error; Save @error state DllCall("kernel32.dll", "int", "CloseHandle", "int", $P_HANDLE[0]) If $error Or Not $Check[0] Then Return "" Return $Check[2] EndFunc Link to comment Share on other sites More sharing options...
Mikon Posted August 10, 2005 Author Share Posted August 10, 2005 big thanks! you really helped me Mikon Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now