CSimpleProcessAPI

Provide simple and cross-platform API to processes and modules.

[ WhoSLocking | Source | Keywords | Summary | Ancestors | All Members | Descendants ]

Quick Index

DESCRIPTION
USAGE
EXAMPLE
ADMINISTRATIVE
SEE ALSO

Class Summary

class CSimpleProcessAPI

{

public:
CSimpleProcessAPI();
~CSimpleProcessAPI();
BOOL BuildProcessList(CMapStringToString &ProcessPIDNameMap);
BOOL BuildModuleList(DWORD nCurrentPID, CStringList &ModuleFileNameList);
BOOL GetProcessesLockingModule(LPCTSTR lpszModuleName, CMapStringToString &PIDNameMap, CMapStringToString &oLoadingProcessMap);
DWORD GetFirstProcessLockingModule(LPCTSTR lpszModuleName, CMapStringToString &PIDNameMap);
CString GetProcessExecutableName(DWORD dwProcessID);
static BOOL TerminateProcess(DWORD dwProcessID);
protected:
}; // CSimpleProcessAPI

Back to the top of CSimpleProcessAPI


DESCRIPTION

This class provides a simple and cross-platform (Windows NT, Windows 98) access to processes and modules (DLLs).

Back to the top of CSimpleProcessAPI


USAGE

To use this class:

Back to the top of CSimpleProcessAPI


EXAMPLE

// Create instance of the class CSimpleProcessAPI oProcessAPI;

// Build list of running processes CMapStringToString oProcessPIDNameMap; if (oProcessAPI.BuildProcessList(oProcessPIDNameMap)) {

POSITION hProcessPosition = NULL;

// Loop on all processes and print their names hProcessPosition = PIDNameMap.GetStartPosition();

if (hProcessPosition != NULL) { cout << "PID\t\tProcess Name\n"; while (hProcessPosition != NULL) { CString ProcessName; CString PIDString; PIDNameMap.GetNextAssoc( hProcessPosition, PIDString, ProcessName ); cout << PIDString << "\t\t" << ProcessName; } } }

Back to the top of CSimpleProcessAPI


ADMINISTRATIVE

Author Emmanuel KARTMANN

Date Monday 12/6/99

Back to the top of CSimpleProcessAPI


SEE ALSO

Back to the top of CSimpleProcessAPI


CSimpleProcessAPI();

Purpose: create an instance of the class

Parameters: none (C++ constructor)

Return value : none (C++ constructor)

Description : This function loads the system DLL (PSAPI.DLL for Windows NT and TOOLHLP32.DLL for Windows 9x) needed to build processes and module lists.

    CSimpleProcessAPI();

Back to the top of CSimpleProcessAPI


~CSimpleProcessAPI();

Purpose: delete an instance of the class

Parameters: none (C++ destructor)

Return value : none (C++ destructor)

Description :

    virtual ~CSimpleProcessAPI();

Back to the top of CSimpleProcessAPI


BOOL BuildProcessList(CMapStringToString &ProcessPIDNameMap);

Purpose: builds the list of running processes

Parameters:

out ProcessPIDNameMap
MFC Map containing all processes (one entry consists of a PID and its associated process name).

Return value : BOOL = TRUE for success, FALSE otherwise

Description :

    BOOL BuildProcessList(CMapStringToString &ProcessPIDNameMap);

Back to the top of CSimpleProcessAPI


BOOL BuildModuleList(DWORD nCurrentPID, CStringList &ModuleFileNameList);

Purpose: builds the list of modules (DLLs) loaded by a given process.

Parameters:

in nCurrentPID
Unique process identifier (PID)
out ModuleFileNameList
List of loaded module file names (full path)

Return value : BOOL = TRUE for success, FALSE otherwise

Description :

    BOOL BuildModuleList(DWORD nCurrentPID, CStringList &ModuleFileNameList);

Back to the top of CSimpleProcessAPI


BOOL GetProcessesLockingModule(LPCTSTR lpszModuleName, CMapStringToString &PIDNameMap, CMapStringToString &oLoadingProcessMap);

Purpose: find the process(es) who is (are) locking a given module (DLL).

Parameters:

in lpszModuleName
name of the module (DLL) to find (full path)
in PIDNameMap
list of all processes (PID/Name map)
out oLoadingProcessMap
list of processes who are locking the given DLL

Return value : BOOL = TRUE for success (at least one process has been found), FALSE otherwise

Description :

    BOOL GetProcessesLockingModule(LPCTSTR lpszModuleName, CMapStringToString &PIDNameMap, CMapStringToString &oLoadingProcessMap);

Back to the top of CSimpleProcessAPI


DWORD GetFirstProcessLockingModule(LPCTSTR lpszModuleName, CMapStringToString &PIDNameMap);

Purpose: find the first process who is locking a given module (DLL).

Parameters:

in lpszModuleName
name of the module (DLL) to find (full path)
in PIDNameMap
list of all processes (PID/Name map)

Return value : DWORD = PID of process who's locking the DLL

Description : Implemented via GetProcessesLockingModule()

    DWORD GetFirstProcessLockingModule(LPCTSTR lpszModuleName, CMapStringToString &PIDNameMap);

Back to the top of CSimpleProcessAPI


CString GetProcessExecutableName(DWORD dwProcessID);

Purpose: returns the name of the process's executable

Parameters:

in dwProcessID
Unique process identifier (PID)

Return value : CString = executable name

Description : This function considers that the executable is a module loaded by the process whose file name extension is ".EXE"

    CString GetProcessExecutableName(DWORD dwProcessID);

Back to the top of CSimpleProcessAPI


BOOL TerminateProcess(DWORD dwProcessID);

Purpose: terminate a process (forcefully)

Parameters:

in dwProcessID
Unique process identifier (PID)

Return value : BOOL = TRUE if process is terminated, FALSE otherwise

Description :

    static BOOL TerminateProcess(DWORD dwProcessID);

Back to the top of CSimpleProcessAPI


All Members

public:
BOOL BuildProcessList(CMapStringToString &ProcessPIDNameMap);
BOOL BuildModuleList(DWORD nCurrentPID, CStringList &ModuleFileNameList);
BOOL GetProcessesLockingModule(LPCTSTR lpszModuleName, CMapStringToString &PIDNameMap, CMapStringToString &oLoadingProcessMap);
DWORD GetFirstProcessLockingModule(LPCTSTR lpszModuleName, CMapStringToString &PIDNameMap);
CString GetProcessExecutableName(DWORD dwProcessID);
static BOOL TerminateProcess(DWORD dwProcessID);
protected:

Back to the top of CSimpleProcessAPI


Ancestors

Class does not inherit from any other class.

Back to the top of CSimpleProcessAPI


Descendants

Class is not inherited by any others.

Back to the top of CSimpleProcessAPI


Generated from source by the Cocoon utilities on Thu Feb 10 12:02:41 2000 .

Report problems to jkotula@stratasys.com