Jump to content
Sign in to follow this  
xenoranger

_WinAPI_GetGuiResources for GDI Object Count

Recommended Posts

xenoranger

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: 2836

GDI Objects: 0

I 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

Share this post


Link to post
Share on other sites
JohnOne

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 by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
xenoranger

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 by xenoranger

Share this post


Link to post
Share on other sites
JohnOne

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.

Share this post


Link to post
Share on other sites
xenoranger

K...

Thank you again, JohnOne for your help.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×