Click here to Skip to main content
15,894,740 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: how to get COleDispatchDriver's point from COleDispatchDriver's handle? Pin
Anthony_Yio7-May-04 0:07
Anthony_Yio7-May-04 0:07 
GeneralRe: how to get COleDispatchDriver's point from COleDispatchDriver's handle? Pin
wl@syntc.com.cn7-May-04 14:35
wl@syntc.com.cn7-May-04 14:35 
GeneralRe: how to get COleDispatchDriver's point from COleDispatchDriver's handle? Pin
Anthony_Yio10-May-04 1:44
Anthony_Yio10-May-04 1:44 
GeneralReading timecode in avi files Pin
FredericCharton6-May-04 21:24
FredericCharton6-May-04 21:24 
GeneralSingle Instance restriction Pin
Mr Bose Dayala6-May-04 19:52
Mr Bose Dayala6-May-04 19:52 
GeneralRe: Single Instance restriction Pin
Monty26-May-04 20:04
Monty26-May-04 20:04 
GeneralRe: Single Instance restriction Pin
Mr Bose Dayala6-May-04 20:11
Mr Bose Dayala6-May-04 20:11 
GeneralRe: Single Instance restriction Pin
Jitendra gangwar6-May-04 20:31
Jitendra gangwar6-May-04 20:31 
Task Manager is an example of a program that enumerates all running processes. It is implemented using data from the performance registry. The following sample code uses the EnumProcesses function to enumerate the current processes in the system. This method is easier than using the performance registry.

#include <windows.h>
#include <stdio.h>
#include "psapi.h"

void PrintProcessNameAndID( DWORD processID )
{
char szProcessName[MAX_PATH] = "unknown";

// Get a handle to the process.

HANDLE hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );

// Get the process name.

if ( hProcess )
{
HMODULE hMod;
DWORD cbNeeded;

if ( EnumProcessModules( hProcess, &hMod, sizeof(hMod),
&cbNeeded) )
{
GetModuleBaseName( hProcess, hMod, szProcessName,
sizeof(szProcessName) );
}
}

// Print the process name and identifier.

printf( "%s (Process ID: %u)\n", szProcessName, processID );

CloseHandle( hProcess );
}

void main( )
{
// Get the list of process identifiers.

DWORD aProcesses[1024], cbNeeded, cProcesses;
unsigned int i;

if ( !EnumProcesses( aProcesses, sizeof(aProcesses), &cbNeeded ) )
return;

// Calculate how many process identifiers were returned.

cProcesses = cbNeeded / sizeof(DWORD);

// Print the name and process identifier for each process.

for ( i = 0; i < cProcesses; i++ )
PrintProcessNameAndID( aProcesses[i] );
}
The main function obtains a list of processes by using the EnumProcesses function. For each process, main calls the PrintProcessNameAndID function, passing it the process identifier. PrintProcessNameAndID in turn calls the OpenProcess function to obtain the process handle. If OpenProcess fails, the output shows only the process identifier. For example, OpenProcess fails for the Idle and CSRSS processes because their access restrictions prevent user-level code from opening them. Next, PrintProcessNameAndID calls the EnumProcessModules function to obtain the module handles. Finally, PrintProcessNameAndID calls the GetModuleBaseName function to obtain the name of the executable file.

This may help u.
/jitendra Laugh | :laugh:

Jitendra Pal Singh Gangwar
E-mail: jitendra_gangwar@hotmail.com
Mobile No: 09831352305
GeneralRe: Single Instance restriction Pin
Jitendra gangwar6-May-04 20:31
Jitendra gangwar6-May-04 20:31 
GeneralCFileFind Pin
ykutanoor6-May-04 19:24
ykutanoor6-May-04 19:24 
GeneralRe: CFileFind Pin
Anonymous6-May-04 21:57
Anonymous6-May-04 21:57 
QuestionHow to detect whether or not the current window is console window. Pin
Truong D. Toan6-May-04 18:14
Truong D. Toan6-May-04 18:14 
AnswerRe: How to detect whether or not the current window is console window. Pin
Abin6-May-04 20:52
Abin6-May-04 20:52 
Questionwhats the CListCtrl's equivalent of SetCurSel ? Pin
Anonymous6-May-04 17:51
Anonymous6-May-04 17:51 
AnswerRe: whats the CListCtrl's equivalent of SetCurSel ? Pin
Anonymous6-May-04 21:30
Anonymous6-May-04 21:30 
QuestionCan anyone help with my code??? Pin
Draco02836-May-04 17:45
Draco02836-May-04 17:45 
AnswerRe: Can anyone help with my code??? Pin
Maxwell Chen6-May-04 19:54
Maxwell Chen6-May-04 19:54 
GeneralRe: Can anyone help with my code??? Pin
Draco02837-May-04 3:05
Draco02837-May-04 3:05 
GeneralRe: Can anyone help with my code??? Pin
Juergen Froehlich7-May-04 11:52
Juergen Froehlich7-May-04 11:52 
Generalamplitude demodulation Pin
langzi546-May-04 14:55
langzi546-May-04 14:55 
GeneralRe: amplitude demodulation Pin
Roger Wright6-May-04 20:39
professionalRoger Wright6-May-04 20:39 
GeneralRe: amplitude demodulation Pin
Anonymous6-May-04 20:55
Anonymous6-May-04 20:55 
GeneralRe: amplitude demodulation Pin
Roger Wright7-May-04 2:59
professionalRoger Wright7-May-04 2:59 
QuestionHow to close Handle in MSVC++ 1.52 Pin
Anonymous6-May-04 14:31
Anonymous6-May-04 14:31 
AnswerRe: How to close Handle in MSVC++ 1.52 Pin
Anthony_Yio6-May-04 15:48
Anthony_Yio6-May-04 15:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.