Click here to Skip to main content
16,011,804 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Directory tree and file list Pin
11-Jan-01 11:01
suss11-Jan-01 11:01 
Generaldao only allows 255 fields Pin
Avigayil11-Jan-01 5:14
Avigayil11-Jan-01 5:14 
GeneralRe: dao only allows 255 fields Pin
David Fedolfi12-Jan-01 8:23
David Fedolfi12-Jan-01 8:23 
GeneralClient-Server :confused: Pin
Maxime Labelle10-Jan-01 22:26
Maxime Labelle10-Jan-01 22:26 
GeneralURGENT:convert from acess97/98 to 2k in VC++ Pin
10-Jan-01 20:18
suss10-Jan-01 20:18 
GeneralATL globals Pin
2sky10-Jan-01 13:56
2sky10-Jan-01 13:56 
GeneralCheck for a running process Pin
ao10-Jan-01 9:16
ao10-Jan-01 9:16 
GeneralRe: Check for a running process Pin
Ghazi H. Wadi10-Jan-01 10:49
Ghazi H. Wadi10-Jan-01 10:49 
If you are writting the other module try creating named Mutex
// Create named mutex
hNamedMutex = CreateMutex(NULL, TRUE, "The Other App");
// Test if the programm is already running
if(GetLastError() == ERROR_ALREADY_EXISTS) {
// Do Somthing
}

If you don't ...
the you have two approaches one is to enumerate the windows by using The EnumWindows function which enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function. EnumWindows continues until the last top-level window is enumerated or the callback function returns FALSE

If you want to enumerate the processes.
Under Windows 95, you must use functions from the ToolHelp32 group of APIs. Under Windows NT, you use functions from PSAPI.DLL, which is available in the Platform SDK.

// Sample Code FOR NT


#include <windows.h>
#include <stdio.h>
#include "psapi.h"
#pragma comment (lib, "psapi.lib")

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] );
}









Hope this helps

Cheers
G. ALfadhly

<marquee>
It is Illogical to define an inventor by his invention

GeneralRe: Check for a running process Pin
11-Jan-01 1:54
suss11-Jan-01 1:54 
GeneralRe: Check for a running process Pin
Ghazi H. Wadi11-Jan-01 4:10
Ghazi H. Wadi11-Jan-01 4:10 
GeneralCheck for a running process Pin
ao10-Jan-01 9:16
ao10-Jan-01 9:16 
GeneralToolbar capture Pin
subir talukder10-Jan-01 5:19
subir talukder10-Jan-01 5:19 
GeneralRe: Toolbar capture Pin
Brendan Tregear10-Jan-01 11:47
Brendan Tregear10-Jan-01 11:47 
GeneralRe: Toolbar capture Pin
subir talukder10-Jan-01 22:02
subir talukder10-Jan-01 22:02 
GeneralRe: Toolbar capture Pin
11-Jan-01 10:12
suss11-Jan-01 10:12 
GeneralRe: Toolbar capture Pin
subir talukder11-Jan-01 21:34
subir talukder11-Jan-01 21:34 
GeneralRe: Toolbar capture Pin
11-Jan-01 23:49
suss11-Jan-01 23:49 
QuestionIs there a program to convert Borland C++ Builder components to VB 6 or MSVS 6? Pin
Chris Bunting10-Jan-01 4:02
Chris Bunting10-Jan-01 4:02 
AnswerRe: Is there a program to convert Borland C++ Builder components to VB 6 or MSVS 6? Pin
Anders Molin10-Jan-01 6:52
professionalAnders Molin10-Jan-01 6:52 
AnswerRe: Is there a program to convert Borland C++ Builder components to VB 6 or MSVS 6? Pin
Erik Funkenbusch10-Jan-01 9:35
Erik Funkenbusch10-Jan-01 9:35 
GeneralWhat's up? My hook works but my program doesn't work Pin
raul10-Jan-01 2:36
raul10-Jan-01 2:36 
GeneralPlay one video file in several windows simultaneously Pin
10-Jan-01 2:32
suss10-Jan-01 2:32 
GeneralUrgent Exception in GetString of ADODB.Recordsset Pin
Alpesh10-Jan-01 1:24
Alpesh10-Jan-01 1:24 
GeneralSound Pin
10-Jan-01 0:58
suss10-Jan-01 0:58 
QuestionCListCtrl and noresize columns ???? Pin
10-Jan-01 0:33
suss10-Jan-01 0:33 

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.