timbCFCA Posted August 9, 2013 Posted August 9, 2013 How can I get the owner of a process when all I have is a handle from WinGetHandle()? Most everything I've seen has been trying to from PIDs to handles. I'm guessing that this needs to go in the opposite direction, and then take the PID and find the user... But I'm not sure how to do it.
FireFox Posted August 9, 2013 Posted August 9, 2013 (edited) Hi,Here you go:#include <Array.au3> #include <WinAPIEx.au3> Run("notepad.exe") Local $iPID = 0 Do $iPID = WinGetProcess("[CLASS:Notepad]") Until $iPID > 0 Local $aUser = _WinAPI_GetProcessUser($iPID) _ArrayDisplay($aUser)Note: This is an example, you only need the WinGetProcess, _WinAPI_GetProcessUser functions Br, FireFox. Edited August 9, 2013 by FireFox
Shrapnel Posted August 9, 2013 Posted August 9, 2013 FireFox, Since the Run function returns the PID, why not just do this: #include <Array.au3> #include <WinAPIEx.au3> Local $iPID = Run("notepad.exe") Local $aUser = _WinAPI_GetProcessUser($iPID) _ArrayDisplay($aUser)
FireFox Posted August 9, 2013 Posted August 9, 2013 (edited) yeah sure. But it was not the point. The OP wanted to have the PID from a window handle. Edited August 9, 2013 by FireFox
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