Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

Identify a process in memory

How do I identify if a process is currently running in memory, in a Windows NT or Windows 98 machine? (How does the task manager show us the current process information?)
To identify programatically using C.
I want only one instance of my application running at a point of time.
0
rishi_raj
Asked:
rishi_raj
  • 2
  • 2
  • 2
  • +2
1 Solution
 
gcauthonCommented:
Go to msdn.microsoft.com and search for psapi (process status api).  You probably want to look at EnumProcesses() first.  This returns the list of pid's and OpenProcess(pid) will give you a handle to the process.  With this you can find anything out about a given process (assuming you have enough security privileges).
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Just wondering.... <text removed from AnnieMod as a private info for another member>

Mayank.
0
 
bkrahmerCommented:
EnumProcesses
Windows 95/98/Me: Unsupported.

You have made the fatal mistake of assuming that you are barking up the right tree in order to solve a problem.  Unfortunately, your approach is not correct.  For one thing, I could make a copy of your .exe, and thereby run two instances.

A very good way ( and commonly used ), is to call CreateEvent, with an arbitrary name (but something that is unlikely to be in use).  If it succeeds, you are the first to own that named object.  Do this near the entry point of your app, and close it right before closing your app.

brian
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
gcauthonCommented:
Why was it a fatal mistake?  Are you going to hunt me down with an AK-47 or something?
0
 
bkrahmerCommented:
It's just an expression.  Chill out dude.  I was just trying to make the point that if people have a question about how to solve a problem, they should simply verify they are taking the correct approach by asking a more general question.  Once they are sure they are using the right approach, then they can worry about how to solve their implementation problems.  No worries.

brian
0
 
rishi_rajAuthor Commented:
Thanks buddies. Let me do a chk at my end.
And Mayank, sorry to disappoint you, I am not Rishi Raj from Michigan.
0
 
jmcgOwnerCommented:
Nothing has happened on this question in more than 9 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by bkrahmer.

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0
 
Mayank SAssociate Director - Product EngineeringCommented:
Thanks for the recommendation. I will follow it. I had seen some experts (who have been using EE for a long time and who have plenty of expert points) doing it, so I thought that there is nothing wrong with it. But I guess it is against some policies.

Regards,
Mayank.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now