TerminateProcess (coredll)
Last changed: -201.6.156.27

.

Summary:

This function terminates the specified process and all of its threads. (From MSDN.)

C# Signature:

[DllImport("CoreDll.dll", SetLastError=true)]
static extern int TerminateProcess(IntPtr processIdOrHandle, IntPtr exitCode);

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Obviously, you need a Process ID to kill. If you want to kill yourself (kill the current process), you'll need GetCurrentProcessId, but as GetCurrentProcessId() is an *inline* function defined in kfuncs.h in Microsoft's "Windows CE Tools" SDK, you can't call it with PInvoke. Use OpenNETCF's implementation, or read the function's inline definition from kfuncs.h and reimplement it in C#.

Sample Code:

Please add some!

Documentation:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecoreos5/html/wce50lrfterminateprocess.asp