Desktop Functions:

   Smart Device Functions:

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

openprocess (kernel32)

C# Signature:

[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr OpenProcess(
     uint processAccess,
     bool bInheritHandle,
     uint processId
public static IntPtr OpenProcess(Process proc, ProcessAccessFlags flags)
     return OpenProcess(flags, false, (uint)proc.Id);

VB.NET Signature:

Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As ProcessAccessFlags, bInheritHandle As Boolean, processId As UInt32) As IntPtr

Boo Signature:

def OpenProcess(dwDesiredAccess as UInt32, bInheritHandle as bool, dwProcessID as UInt32) as IntPtr:

User-Defined Types:

    public enum ProcessAccessFlags : uint
        All = 0x001F0FFF,
        Terminate = 0x00000001,
        CreateThread = 0x00000002,
        VirtualMemoryOperation = 0x00000008,
        VirtualMemoryRead = 0x00000010,
        VirtualMemoryWrite = 0x00000020,
        DuplicateHandle = 0x00000040,
        CreateProcess = 0x000000080,
        SetQuota = 0x00000100,
        SetInformation = 0x00000200,
        QueryInformation = 0x00000400,
        QueryLimitedInformation = 0x00001000,
        Synchronize = 0x00100000

    Public Enum ProcessAccessFlags As UInteger
    All = &H1F0FFF
    Terminate = &H1
    CreateThread = &H2
    VirtualMemoryOperation = &H8
    VirtualMemoryRead = &H10
    VirtualMemoryWrite = &H20
    DuplicateHandle = &H40
    CreateProcess = &H80
    SetQuota = &H100
    SetInformation = &H200
    QueryInformation = &H400
    QueryLimitedInformation = &H1000
    Synchronize = &H100000
    End Enum


See also CloseHandle,

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