Jump to content

_WinAPI_GetGuiResources for GDI Object Count


Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...