首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

OperService失败,返回异常码为5

2013-03-16 
OperService失败,返回错误码为5最近在做一个项目,里面用到了OperService去打开windows系统的服务,发现若设

OperService失败,返回错误码为5
最近在做一个项目,里面用到了OperService去打开windows系统的服务,发现若设置生成的exe文件属性-》兼容性-》用兼容性模式运行这个程序后,OperService就会失败,请问谁知道是什么原因。
另外,是不是如果用户不是用管理员身份登录的时候,OperService也会失败呢,谢谢。
[解决办法]
看你是以什么权限打开了,权限不够当然会出问题
OpenService
dwDesiredAccess 
[in] Specifies the access to the service. Before granting the requested access, the system checks the access token of the calling process against the discretionary access-control list of the security descriptor associated with the service object. 
The STANDARD_RIGHTS_REQUIRED constant enables the following object access types. 
========================
5 Access is denied.  ERROR_ACCESS_DENIED 
确实是权限不够,以管理员身份运行程序吧

热点排行