Process '& Module Enumeration Class | CodeGuru

Process ‘& Module Enumeration Class

This article presents a class (CPSAPI) which can be used to enumerate all of the processes, modules and even device drivers currently executing on either a Windows 9x or Windows NT machine. As you can see in the provided demo application, this class is extremely easy to use. All you need to is the following: […]

Written By
CodeGuru Staff
CodeGuru Staff
Feb 9, 2000
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

This article presents a class (CPSAPI) which can be used to enumerate all of the
processes, modules and even device drivers currently executing on either a
Windows 9x or Windows NT machine.

As you can see in the provided demo application, this class is extremely easy
to use. All you need to is the following:


  • Derive a class from the CPSAPI base class

  • Implement the derived class’ OnXXX method that correlates to the desired function:


    • virtual BOOL OnDeviceDriver(LPVOID lpImageBase);

    • virtual BOOL OnProcess(LPCTSTR lpszFileName, DWORD ProcessID);

    • virtual BOOL OnModule(HMODULE hModule, LPCTSTR lpszModuleName, LPCTSTR lpszPathName);


  • Instantiate your object

  • Call the object’s Initialize method

  • Call the desired enumeration function:


    • BOOL EnumDeviceDrivers(void);

    • BOOL EnumProcesses(void);

    • BOOL EnumProcessModules(DWORD dwProcessId);


If this sounds a bit difficult, not to worry. A demo application I included with this article
illustrates how to do all this.

Downloads

Download demo project – 19 Kb

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.