OpenProcess使用PROCESS_ALL_ACCESS返回ERROR_ACCESS_DENIED

原文地址

http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/eeb93be6-872c-4028-b0ae-cd873e089825

 

Rajeesh... _

Rajeesh... _

Ness technologies

280 Points 5 0 0
Recent Achievements
First Helpful Vote Forums Replies I Forums Answerer I
Ness technologies

280 Points

   Answered
I just went through OpenProcess API in msdn, it says below for for PROCESS_ALL_ACCESS. I think this was the issue which you were facing.

Windows Server 2003 and Windows XP/2000:   The size of the PROCESS_ALL_ACCESS flag increased on Windows Server 2008 and Windows Vista. If an application compiled for Windows Server 2008 and Windows Vista is run on Windows Server 2003 or Windows XP/2000, the PROCESS_ALL_ACCESS flag is too large and the function specifying this flag fails with ERROR_ACCESS_DENIED. To avoid this problem, specify the minimum set of access rights required for the operation. If PROCESS_ALL_ACCESS must be used, set _WIN32_WINNT to the minimum operating system targeted by your application (for example,#define _WIN32_WINNT _WIN32_WINNT_WINXP). For more information, seeUsing the Windows Headers .

 

Windows Server 2008及Windows Vista上PROCESS_ALL_ACCESS的标志有所增加,如果应用程序编译时的target OS是Windows Server 2008或Windows Vista, 但却运行在Windows Server 2003或Windows XP/2000上,PROCESS_ALL_ACCESS太大,指定这个标志的函数会返回ERROR_ACCESS_DENIED错误。如果避免这个错误,指定操作所需的最小访问权限,而不是图省事指定PROCESS_ALL_ACCESS. 如果必须要用PROCESS_ALL_ACCESS, 要在程序中定义_WIN32_WINNT _WIN32_WINNT_WINXP

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值