未分类--Windows API--OpenProcess

150 篇文章 0 订阅
3 篇文章 0 订阅

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

 

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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值