Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
terminateprocess (coredll)

coredll is for smart devices, not desktop Windows. Therefore, this information only applies to code using the .NET Compact Framework. To see if information for terminateprocess in other DLLs exists, click on Find References to the right.



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

VB Signature:

Declare Function TerminateProcess Lib "coredll.dll" (ByVal processIdOrHandle As IntPtr, ByVal exitCode As IntPtr) As Integer

User-Defined Types:


Alternative Managed API:

Do you know one? Please contribute it!



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:

/* GetCurrentProcessId() and constants translated from kfuncs.h (SmartPhone2003) to C# */
const int SH_CURPROC = 2;
const int SYS_HANDLE_BASE = 64;
IntPtr GetCurrentProcessId()
   return ((IntPtr)(SH_CURPROC + SYS_HANDLE_BASE));
private void menuItem1_Click(object sender, EventArgs e)
    TerminateProcess(GetCurrentProcessId(), (IntPtr)0);


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version