未分类--Windows API--OpenProcess

原文来自MSDN Library for Visual Studio 2008 SP1,翻译部分仅为个人观点,想要看更多信息请看MSDN,如有版权问题请联系QQ 643166601,邮件[email protected]

 

OpenProcess Function

Opens an existing local process object.
打开存在的本地进程对象。

Syntax
HANDLE WINAPI OpenProcess(
  __in  DWORD dwDesiredAccess,
  __in  BOOL bInheritHandle,
  __in  DWORD dwProcessId
);

Parameters
dwDesiredAccess
The access to the process object. This access right is checked against the security descriptor for the process. This parameter can be one or more of the process access rights.
访问进程对象。访问权利是再一次的检查进程的安全描述符。这个参数可以一个或更多的进程访问权限。

If the caller has enabled the SeDebugPrivilege privilege, the requested access is granted regardless of the contents of the security descriptor.
如果调用者启用了SeDebugPrivilege权限,请求权限是准许安全描述符是毫无价值的内容。

bInheritHandle
If this value is TRUE, processes created by this process will inherit the handle. Otherwise, the processes do not inherit this handle.
如果这个值是TRUE,这个进程创建的进程将继承这个句柄。否则,进程将不继承这个句柄。

dwProcessId
The identifier of the local process to be opened.
将要打开本地继承的标识符。

Return Value
If the function succeeds, the return value is an open handle to the specified process.
如果函数成功,返回值是打开句柄的指定的进程。

If the function fails, the return value is NULL. To get extended error information, call GetLastError.
如果函数失败,返回值是NULL。要获得额外的错误信息,请调用GetLastError。

Remarks
To open a handle to another local process and obtain full access rights, you must enable the SeDebugPrivilege privilege. For more information, see Changing Privileges in a Token.
要打开一个句柄到另一个本地进程并且获得全部访问权限,你必须启用SeDebugPrivilege权限。更多信息,请看Changing Privileges in a Token。

The handle returned by the OpenProcess function can be used in any function that requires a handle to a process, such as the wait functions, provided the appropriate access rights were requested.
通过OpenProcess函数返回的句柄可以在任何函数中使用,请求进程的句柄,例如wait functions,请求适当的访问权限。

When you are finished with the handle, be sure to close it using the CloseHandle function.
当你完成这个句柄,确信使用CloseHandle函数关闭它。

Example Code
For an example, see Taking a Snapshot and Viewing Processes.

Requirements
Client Requires Windows Vista, Windows XP, or Windows 2000 Professional.
Server Requires Windows Server 2008, Windows Server 2003, or Windows 2000 Server.
Header Declared in Winbase.h; include Windows.h.
 
Library Use Kernel32.lib.
 
DLL Requires Kernel32.dll.
 

See Also
AssignProcessToJobObject
CloseHandle
CreateProcess
CreateRemoteThread
DuplicateHandle
GetCurrentProcess
GetCurrentProcessId
GetExitCodeProcess
GetModuleFileNameEx
GetPriorityClass
Process and Thread Functions
Processes
ReadProcessMemory
SetPriorityClass
SetProcessWorkingSetSize
TerminateProcess
VirtualProtectEx
WriteProcessMemory

 

Send comments about this topic to Microsoft

Build date: 4/24/2008

 

你可能感兴趣的:(windows,api)