Click here to Skip to main content
11,924,800 members (51,132 online)
Click here to Skip to main content
Add your own
alternative version


24 bookmarked

Accessing Process Information Using the Win32 API

, 8 Nov 2006 GPL3
Rate this:
Please Sign up or sign in to vote.
An article on accessing process information using the Win32 API.

Sample Image


Calling System.Diagonistics.Process.GetProcesses() on a hyper-threading (possibly true multi-proc) computer running Windows 2000 fails with: "Couldn't get process information from remote machine ---> System.ArgumentOutOfRangeException: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks." The same error can occur if your registry key HKEY_LOCAL_MACHINE.Software.Microsoft.WindowNT.CurrentVersion.PerfLib is corrupted. The solution for this problem is to get process  information using win32 API.

Using the code

This Win32 API implementation project consists of one key file: Processes.cs which implements the Win32 functions for Process List, Process IDs, and killing a process by process ID. An example project is also included in the source code that demonstrates the basic usage of the Process class.

Simply build and run the project, you will see a Windows form that has a listbox loading all system processes. You can select any process and just click the KILL button, and the selected process will be killed by using the Win32 API implementation.

private void btnKill_Click(object sender, System.EventArgs e)
    string strProcessName=
    uint processId=Convert.ToUInt32(
        MessageBox.Show("Process is killed successfully");
        MessageBox.Show("Process cannot be Killed");

public static bool Kill(uint uiProcessId)
    System.IntPtr handler= 
    bool b=Win32Processes.Processes.KillProcess(handler);
    return b; 


  • Initial release - 8th November 2006.


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


About the Author

Waheed Iqbal
Pakistan Pakistan
Waheed is a student of Master leading to PhD (computer sciences) at AIT ( His area of research is High performance computing(HPC). Prior to this he was attached with Compass partners Inc. and Mazik Pakistan as a Software Engineer.

You may also be interested in...

Comments and Discussions

QuestionNice article Pin
WuRunZhe11-Dec-13 2:45
memberWuRunZhe11-Dec-13 2:45 
GeneralThank you very much Pin
kasparovthe217-Feb-09 9:39
memberkasparovthe217-Feb-09 9:39 
GeneralThanks! Pin
equi4y3q420-Aug-08 1:18
memberequi4y3q420-Aug-08 1:18 
GeneralGreat!.... Pin
Member 297619318-Jun-08 20:14
memberMember 297619318-Jun-08 20:14 
GeneralProcess hangs Pin
RajeshTech14-Oct-07 20:26
memberRajeshTech14-Oct-07 20:26 
GeneralA suggestion Pin
Mohamad K Ayash5-Sep-07 4:51
memberMohamad K Ayash5-Sep-07 4:51 
Very Good Work work but let me suggset to you regarding shape(not content) to create instead of a listbox a listview item that lists in a well organized manner the process name, ID, mainwindowcaption, icon, number of threads, priority,...etc.(You may not need to use win32 api though, but you may).

Best Wishes...

To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!

GeneralRe: A suggestion Pin
Waheed Iqbal5-Sep-07 10:29
memberWaheed Iqbal5-Sep-07 10:29 
GeneralThank you so much Pin
soniavdas2-Jul-07 10:03
membersoniavdas2-Jul-07 10:03 
GeneralAccessing Process Information Using the Win32 API Pin
Squall_aow10-Dec-06 17:23
memberSquall_aow10-Dec-06 17:23 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151125.3 | Last Updated 8 Nov 2006
Article Copyright 2006 by Waheed Iqbal
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid