xenoranger Posted January 17, 2013 Share Posted January 17, 2013 I'm trying to get a GDI Object count using the _WinAPI_GetGuiResources function. From what I understand, I should use the 0 flag to get a count of GDI Objects. The 2nd parameter is the PID. When I run the code below, I get the following output:Output:PID: 2836GDI Objects: 0I know that PID 2836 is associated with 4 GDI Objects (according to TaskMan). Any thoughts why this code isn't returning the correct number of GDI Objects? #include <Array.au3>; Only for _ArrayDisplay() #include <Date.au3> #include <WinAPI.au3> #include <File.au3> #include <_ArraySize.au3> Global Const $GR_GDIOBJECTS = 0 Local $PID = 2836 ;WinGetProcess("RD Tabs") consolewrite(@crlf & "PID: " & $PID & @crlf & "GDI Objects: " & _WinAPI_GetGuiResources($GR_GDIOBJECTS,$PID) & @crlf & @CRLF) Exit Link to comment Share on other sites More sharing options...
JohnOne Posted January 17, 2013 Share Posted January 17, 2013 Because that function takes a process handle, not a pid. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted January 17, 2013 Share Posted January 17, 2013 (edited) Local Const $GR_GDIOBJECTS = 0 Local Const $iAccess = 2035711 Local Const $fInherit = 0 Local $PID = ProcessExists("notepad.exe") Local $hProc = _WinAPI_OpenProcess($iAccess, $fInherit, $PID) If @error Then Exit MsgBox(0, "error", @error) MsgBox(0, "GDI Objects", _WinAPI_GetGuiResources($GR_GDIOBJECTS, $hProc)) EDIT: unsure if you should use _WinAPI_CloseHandle() on $hProc Edited January 17, 2013 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
xenoranger Posted January 18, 2013 Author Share Posted January 18, 2013 (edited) Why would I need to use _WinAPI_CloseHandle() on $hProc?100% of what I know is self taught, so I'm still a complete newb at programming.EDIT: Worked like a charm. Thank you so much!! Edited January 18, 2013 by xenoranger Link to comment Share on other sites More sharing options...
JohnOne Posted January 18, 2013 Share Posted January 18, 2013 Why would I need to use _WinAPI_CloseHandle() on $hProc?I don't know, because it's a handle was my thinking, before seeing that only File* funcs were mentioned in it's 'see also' section.Certainly wont matter in that code because everything is released upon exit, but I would still ask someone better in the know if it were me using it in a loop. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
xenoranger Posted January 21, 2013 Author Share Posted January 21, 2013 K... Thank you again, JohnOne for your help. 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