Click here to Skip to main content
11,926,429 members (60,112 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ Windows API

I have a serious problem about OpenProcess function (link to msdna).

I need that function to get all process handles, to collect basic information (process name, cpu usage, memory usage) about the currently running processes. The problem is when I build a release version of my application some process handle cannot be opened with this function (debug version open these handles succesfully). I've tried several solution, but some of them have a bottleneck. This "solutions" was:
- Initialize privileges, also need Open Process function, the failure was my application cannot open its own handle.
- Tried other function to get process name and cpu usage (these are ok)

Unfortunately, I cannot found another way to get memory usage of processes, thats is why OpenProcess needs to be solved, but if you have an idea to collect memory usage info without OpenProcess please let me know that or solve the OpenProcess failure.

Sorry about not sharing the program code, but its trade secret currently.
Posted 19-Jul-13 5:36am
Richard MacCutchan 19-Jul-13 11:30am
How can your code be a trade secret when it is merely using the Windows API to get process handles?
Richard MacCutchan 19-Jul-13 11:31am
Are you running your application with administrator privileges?
dur4N 19-Jul-13 11:34am
Good question Smile | :) To be honest, I don't want to get in trouble at my workplace.
dur4N 19-Jul-13 11:35am
Yes I am running with administation privileges

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

It's not quite clear, according to your description, what's going on and what you are trying to achieve, exactly; probably you need to enumerate processes:[^],[^].

Alternatively, if you are interested in the information on just one process, you can get the handle of this process outside of this process, on in the process itself. For outside approach, you have to create the process in some other process and obtain the process handle in the parent process:[^].

If you want to do it in your current process, you need to obtain your current process handle and do the same:[^].

Espen Harlinn 19-Jul-13 19:37pm
Sergey Alexandrovich Kryukov 19-Jul-13 20:26pm
Thank you, Espen.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 19 Jul 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100