stinger Posted November 13, 2010 Share Posted November 13, 2010 I've wrote a sample code to get my proc handle but dont know why it always return 0xffffffff Here's my code #include <WinAPI.au3> $hwnd = _WinAPI_GetCurrentProcess() $procid = _WinAPI_GetCurrentProcessID() MsgBox(0, "Info", $hwnd) MsgBox(0, "Info", $procid) GetCurrentProcessID is working good but GetCurrentProcess does not work, there's no error. Am i missing something ? Link to comment Share on other sites More sharing options...
Yashied Posted November 13, 2010 Share Posted November 13, 2010 (edited) This is a confusion in the description. _WinAPI_GetCurrentProcess() returns a pseudo handle of the current process, not a real handle. #Include <WinAPI.au3> $PID = _WinAPI_GetCurrentProcessID() $hProcess = _WinAPI_GetCurrentProcess() $Ret = DllCall('kernel32.dll', 'bool', 'DuplicateHandle', 'ptr', $hProcess, 'ptr', $hProcess, 'ptr', $hProcess, 'ptr*', 0, 'dword', 0, 'bool', 0, 'dword', 2) ConsoleWrite('PID: ' & $PID & @CR) ConsoleWrite('Pseudo handle: ' & $hProcess & @CR) ConsoleWrite('Real handle: ' & $Ret[4] & @CR) Edited November 13, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
stinger Posted November 13, 2010 Author Share Posted November 13, 2010 This is a confusion in the description. _WinAPI_GetCurrentProcess() returns a pseudo handle of the current process, not a real handle. #Include <WinAPI.au3> $PID = _WinAPI_GetCurrentProcessID() $hProcess = _WinAPI_GetCurrentProcess() $Ret = DllCall('kernel32.dll', 'bool', 'DuplicateHandle', 'ptr', $hProcess, 'ptr', $hProcess, 'ptr', $hProcess, 'ptr*', 0, 'dword', 0, 'bool', 0, 'dword', 2) ConsoleWrite('PID: ' & $PID & @CR) ConsoleWrite('Pseudo handle: ' & $hProcess & @CR) ConsoleWrite('Real handle: ' & $Ret[4] & @CR) Thanks alot for your reply. Link to comment Share on other sites More sharing options...
KaFu Posted November 13, 2010 Share Posted November 13, 2010 (edited) So... what's the difference to @AutoItPID? Edit: Reread the post and realized that you wanted to obtain the process handle ... and also that the "Delete" post does not seem to work. Edited November 13, 2010 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) 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