HOW DO I KNOW HOW MANY SAME EXE FILES RUNNING IN MY WINDOWS?

Hi,

I am using Visual C++ to build my program. How do I get the counter for this program currently running in my windows. For example, I am open six SAMPLE.EXE in my windows. How do I get the '6'? Thank you.
kimhengAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

info_expertCommented:
Hi,

Most appropriate is:

http://support.microsoft.com/kb/q243953/


Otherwise check:

At every time you instanciate your application, you will have to increment a specific value in the registery of the windows. you may create (or check the if entery previously created) in the registery and then increment the value.

Other option is to create a specific environment variable and increment.

Regards.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
info_expertCommented:
Also

See manual for GlobalAddAtom() and GlobalFindAtom().


Its far easier than the previousl mentioned techs.

Regards.
0
PaulCaswellCommented:
If you just want to make sure there is only one of you then use a Mutex:

HANDLE hInstanceMutex = NULL;      // Stops me launching twice.

...

      // Have we launched before?
      hInstanceMutex = ::CreateMutex(NULL,TRUE, mutexName);
    if(GetLastError() != ERROR_ALREADY_EXISTS)
      {

...

      if(hInstanceMutex)
    {
        CloseHandle(hInstanceMutex);
    }

Paul
0
jkrCommented:
>>How do I get the counter for this program currently running in my windows.

The easiest way:

http://support.microsoft.com/kb/q175030/ ("How To Enumerate Applications Using Win32 APIs")

This is the code the task manager uses to list alll running processes. You basically have to add

            // Did we just bump into our process?
            if (_stricmp(szFileName, "MYPROCESS.EXE") == 0) {

                   ++nMyProcessCount;
            }
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.