RE: Determine Handle Count associated with a running process.

From: Ran Liang[MSFT] (v-liangr_at_online.microsoft.com)
Date: 02/24/04


Date: Tue, 24 Feb 2004 12:18:00 GMT

Hi icontin,

Thank you for posting in the community!

First of all, I'd like to confirm my understanding of your issue. You
indicated that you want to get the handle counts of object handles in a
process. Have I fully understood you? If there's any misunderstanding,
please feel free to let me know.

Based on my research, I suggest you to use Windows Management
Instrumentation (WMI) to implement the corresponding function. WMI provides
you with a standard way to interact with system management information and
the underlying WMI APIs.

I have created a test project in VB codes on my site, which gets handle
counts of all the running process on the local machine, and I pasted the
source codes as follows for your reference.
Please note that before running the vb codes, you should add the "Microsoft
WMI Scripting V1.2 Library" reference in VB at first.

[Reference Codes]
Private Sub Command1_Click()
For Each Process In
GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_pr
ocess")

'get process name
Dim aa As String
Debug.Print Process.name
aa = Process.name
aa = Left(aa, Len(aa) - 4)

'get handle counts
Set RawProc =
GetObject("winmgmts:Win32_PerfRawdata_Perfproc_process.name='" + aa + "'")
Set CookedProc =
GetObject("winmgmts:Win32_Perfformatteddata_Perfproc_process.name='" + aa +
"'")

Debug.Print aa & " process HandleCount" & RawProc.HandleCount
Debug.Print aa & " Process HandleCount" & CookedProc.HandleCount

Next

End Sub

If you have any other problems or concerns, please feel free to post it in
the community. I'm always standing by to be of assistance.

Best Regards,

Liang Ran [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.



Relevant Pages

  • RE: Change IE Proxy Settings
    ... Thanks for posting in the community. ... I am not very clear about how to change the IE Proxy settings with WMI, ... This posting is provided "AS IS" with no warranties, ...
    (microsoft.public.win32.programmer.wmi)
  • Re: PolAdtEv
    ... I did try posting a question about this on ... entire array instead of just the first 254 characters? ... >This is more a WMI question and not SMS related. ... tried tojsut get the data from the registry into ...
    (microsoft.public.sms.inventory)
  • RE: WMI to SNMP problems
    ... community first, in order to make sure it's given to WMI so the SNMP WMI ... PLEASE NOTE the newsgroup SECURE CODE and PASSWORD will be updated at 9:00 ...
    (microsoft.public.win32.programmer.wmi)
  • Re: corrupt local area connection advanced properties
    ... This posting is provided "AS IS" with no warranties, ... The WMI recovery approach did not work. ... I've seen other posting/web sites suggesting that you delete the>>>Windows\system32\wbem\repository files. ... >> Please post any reply as a follow-up message in the news group ...
    (microsoft.public.windowsxp.network_web)
  • Re: Rerun an advertised program on Advanced client
    ... This info is not stored in WMI but in registry. ... This posting is provided "AS IS" with no warranties, and confers no rights. ...
    (microsoft.public.sms.swdist)