Simple Process Viewer
Posted
by Vineet Nandurkar
on February 9th, 2001

While the overall scope of the application may be narrow, the code does illustrate how to use of Tool Help Library provided by Microsoft in order to obtain vital information about running processes. Below is the salient code for this purpose.
Note that specifically the application makes use of the process functions Process32First and Process32Next to find all the running processes in the system.
void CProcessViewerDlg::ShowProcessData()
{
// Get the snapshot of the system
hSnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPALL, NULL);
PROCESSENTRY32 pEntry;
pEntry.dwSize = sizeof(pEntry);
//Buffer for Process Info
char szProcessInfo[255];
/Get first process
Process32First(hSnapShot, &pEntry);
//Iterate thru all processes
while(1)
{
BOOL hRes=Process32Next (hSnapShot,&pEntry);
if(hRes==FALSE)
break;
sprintf(szProcessInfo,"%d",pEntry.th32ProcessID );
m_list.InsertItem(0,pEntry.szExeFile);
m_list.SetItemText(0,0,pEntry.szExeFile);
m_list.SetItemText(0,1,szProcessInfo);
sprintf(szProcessInfo,"%d",pEntry.cntThreads );
m_list.SetItemText(0,2,szProcessInfo);
sprintf(szProcessInfo,"%d",pEntry.th32ParentProcessID);
m_list.SetItemText(0,3,szProcessInfo);
sprintf(szProcessInfo,"%d",pEntry.pcPriClassBase );
m_list.SetItemText(0,4,szProcessInfo);
}
}

Comments
this error is coming while Building project
Posted by madhusudhanv on 03/07/2006 05:25amThe compilation is done successfully , but building this error is coming ??? --------------------Configuration: ProcessViewer - Win32 Debug-------------------- Compiling... TaskManagerEx.cpp c:\process\taskmanager1\taskmanagerex\taskmanagerex\taskmanagerex.cpp(6) : fatal error C1083: Cannot open include file: 'LoadDll.h': No such file or directory Error executing cl.exe. ProcessViewer.exe - 1 error(s), 0 warning(s)
ReplyHow can I find out...
Posted by Legacy on 02/23/2004 12:00amOriginally posted by: Punga
If I have only PID how can I find out if the current process works or not? I can't get HANDLE of some processes(There are no sufficient rights).
Replystartup manager
Posted by Legacy on 06/04/2003 12:00amOriginally posted by: gaurav
How can i know which are the application currently installed in startup Manager.How can i access them with win32 program with their path and icon.
ReplyI have a problem while linking the demo code?
Posted by Legacy on 04/25/2003 12:00amOriginally posted by: Vijaya
Hello,
I downloaded the demo files and tried to build the processviewer.exe. I get the following error.
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
libcd.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/ProcessViewer.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
ProcessViewer.exe - 4 error(s), 0 warning(s)
What files am I missing?
Thanks,
ReplyVijaya
How I can close any program.
Posted by Legacy on 04/09/2003 12:00amOriginally posted by: Rehan Shaukat
Hello,
I want to close any programm running on window. please help me.
THanx in advance.
ReplyRehan
how to get my installed software's name and its (exe) filename
Posted by Legacy on 09/12/2002 12:00amOriginally posted by: zhang
How do I get my computer's installed-softwares'name
Replyand its (exe)filename before executing the software,
such as,I have installed office2000 software, but I
can't know how to get its (exe)filename and its fullpath
I need it very much
How can u view window captions like in ctrl-alt-dlt
Posted by Legacy on 07/24/2002 12:00amOriginally posted by: jimmy
how can u view window captions like in ctrl-alt-dlt.
Replyplease e-mail me it would be much appreciated
cntUsage - How can I display CPU - Usage?
Posted by Legacy on 07/04/2002 12:00amOriginally posted by: pat
Hey!
so you written the program, but why you did not implement the cpu usage? can you make an update?
or can you tell me why the pEntry.cntUsage returns 0 ?
well i think you mastered the problem, i plea you to share your experience.
thx pat.
ReplyProcessViewer.exe- Entry Point Not Found
Posted by Legacy on 06/03/2002 12:00amOriginally posted by: mar
When I tried to run it, the following error message
appears. " The procedure entry point Process32First could
not be located in the dynamic link library KERNEL32.dll "
Please Help !!!
I don't know what to do...
Replytic.exe and Process32First ???
Posted by Legacy on 02/05/2002 12:00amOriginally posted by: Concerned Individual
Hello. I am in need of some advice/help. We are running a small office with a server using WindowsNT (Service Pack 4, Version 6a). Lately, we have noticed an error message pop-up each time after a fresh boot. The message reads as follows:
"The prodcedure entry point Process32First could not be located in the dynamic link library Kernel32.dll."
Would you have any suggestions for someone who is not too familiar with computer coding? Would adding this .dll file solve my problems? I would be able to follow directions if given a step-by-step instructions. Thank you.
Sincerely,
Bert
ReplyLoading, Please Wait ...