?
Solved

Identify a process in memory

Posted on 2003-03-26
10
Medium Priority
?
288 Views
Last Modified: 2010-04-15
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
Comment
Question by:rishi_raj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
10 Comments
 
LVL 3

Expert Comment

by:gcauthon
ID: 8210213
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 8210248
Just wondering.... <text removed from AnnieMod as a private info for another member>

Mayank.
0
 
LVL 2

Accepted Solution

by:
bkrahmer earned 80 total points
ID: 8223045
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
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!

 
LVL 3

Expert Comment

by:gcauthon
ID: 8225390
Why was it a fatal mistake?  Are you going to hunt me down with an AK-47 or something?
0
 
LVL 2

Expert Comment

by:bkrahmer
ID: 8226117
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
 

Author Comment

by:rishi_raj
ID: 8243610
Thanks buddies. Let me do a chk at my end.
And Mayank, sorry to disappoint you, I am not Rishi Raj from Michigan.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10194567
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
 
LVL 30

Expert Comment

by:Mayank S
ID: 10206732
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

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.

Question has a verified solution.

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

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

770 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