Jump to content

Recommended Posts

Posted

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

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

Monkey's are, like, natures humans.

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

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.

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
  • Recently Browsing   0 members

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