读书人

OperService失败返回异常码为5

发布时间: 2013-03-16 11:51:46 作者: rapoo

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
确实是权限不够,以管理员身份运行程序吧

读书人网 >VC/MFC

热点推荐