473,387 Members | 1,611 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

get list of pid of all processes running on the system

how to get list of pid of all processes running on the system using c++ in windows???
Jun 21 '07 #1
6 9604
weaknessforcats
9,208 Expert Mod 8TB
Try EnumProcess() in psapi.h.
Jun 21 '07 #2
Try EnumProcess() in psapi.h.
its giving error
process error LNK2019: unresolved external symbol _EnumProcesses@12 referenced in function _main
Jun 21 '07 #3
its giving error
process error LNK2019: unresolved external symbol _EnumProcesses@12 referenced in function _main
Expand|Select|Wrap|Line Numbers
  1. include <windows.h>
  2. #include<psapi.h>
  3. #include <iostream>
  4. using namespace std;
  5. int main() {
  6.  
  7.   u_long a[100];
  8.   u_long rsize;
  9.  
  10.  EnumProcesses(a,sizeof(a),&rsize);
  11.  return 0;
  12. }
  13.  
Jun 21 '07 #4
weaknessforcats
9,208 Expert Mod 8TB
Quote:
Originally Posted by happiness4all
its giving error
process error LNK2019: unresolved external symbol _EnumProcesses@12 referenced in function _main


Code: ( cpp )
include <windows.h>
#include<psapi.h>
#include <iostream>
using namespace std;
int main() {

u_long a[100];
u_long rsize;

EnumProcesses(a,sizeof(a),&rsize);
return 0;
}
You forgot to add psapi.lib to your build as an additional linker dependency.

This code compiles and links with no errors on Visual Studio.NET 2005 after I added psapi.lib to the build.
Jun 21 '07 #5
You forgot to add psapi.lib to your build as an additional linker dependency.

This code compiles and links with no errors on Visual Studio.NET 2005 after I added psapi.lib to the build.
u r rite i also added the lib then it worked fine.
why do we have to add some libslike wsock32.lib when we use winsock..etc.
Jun 21 '07 #6
weaknessforcats
9,208 Expert Mod 8TB
why do we have to add some libslike wsock32.lib when we use winsock..etc.
Libraries are just precompiled code. Otherwise, you would need the source code. So, you use the header provided with the library and you add the library as a linker dependency.

For example, you can create your own library with youe favorite functions in it and to the same.
Jun 22 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Roger | last post by:
I would like to get a list of running processes on a remote machine. How is this possible via VB.Net? Is it possible? Can someone point me in the right direction. thanks, rog
1
by: Al Sav | last post by:
Hello, I am trying to find the file location and file names of all the processes that I see in windows task manager. How can I list all the exes that are running currently? Thanks in advance,...
1
by: Leonid | last post by:
Hello, How to get the list of running processes in VC++ (Similar to Task Manager->Processes window) Regards Leonid
5
by: Simon Hart | last post by:
Does anyone know the standard code access permission to be able to manipulate a process using the Process class? Thanks Simon.
2
by: masterra | last post by:
Hello all! I am trying to create a replacement task bar for windows (don't ask why..) in C#, and have run into some troubles. I am aware that i can get a list of running processes (using...
1
by: JezB | last post by:
I want to iterate the process list looking at the processes running for the current user. So I'm using: foreach (Process p in Process.GetProcesses()) { } But I can't see any method or...
5
by: Andy Baker | last post by:
Our VB.NET 2003 application requires several processes to run overnight. I have written a program to perform these processes with a simple user interface to allow the user to switch various options...
2
by: Troy Matteoli | last post by:
I'm having an issue running some java processes on a Windows server. My system has serveral java processes that are started in the background by a system service. They are run as the SYSTEM user....
4
by: commander_coder | last post by:
Hello, I write a lot of CGI scripts, in Python of course. Now I need to convert some to long-running processes. I'm having trouble finding resources about the best practices to do that. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.