Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2004-11-19
7
Medium Priority
?
188 Views
Last Modified: 2010-05-19
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.
0
Comment
Question by:kimheng
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
info_expert earned 672 total points
ID: 12623330
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
 
LVL 5

Expert Comment

by:info_expert
ID: 12623373
Also

See manual for GlobalAddAtom() and GlobalFindAtom().


Its far easier than the previousl mentioned techs.

Regards.
0
 
LVL 16

Assisted Solution

by:PaulCaswell
PaulCaswell earned 664 total points
ID: 12623532
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
 
LVL 86

Assisted Solution

by:jkr
jkr earned 664 total points
ID: 12625598
>>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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question