Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


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

OpenProcess (kernel32)
 
.
Summary

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);
     return OpenProcess(flags, false, proc.Id);
}

VB.NET Signature:

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

Boo Signature:

[DllImport("kernel32.dll")]
def OpenProcess(dwDesiredAccess as UInt32, bInheritHandle as bool, dwProcessID as UInt32) as IntPtr:
     pass

User-Defined Types:

    [Flags]
    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
    }

    <Flags>
    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

Notes:

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 PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions