检查服务是否从 DLL 运行
我已经在 Windows7 计算机中注册了 COM 上下文菜单 DLL(以显示资源管理器上下文菜单)。在DLL中,我检查了系统中是否有服务正在运行。该服务在“本地系统帐户”下运行。
我已通过 OpenSCManager
和 QueryServiceStatus
检查了服务状态。看来在XP下没有任何问题。但在Windows7中,有时我会收到“拒绝访问”错误,有时会得到错误的结果...(例如,服务正在运行,但它显示服务已停止的状态。)我不知道如何在Windows7中检查这一点。
我还检查了我的 exe 是否正在运行,
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, aProcesses[i]);
但是当我作为服务运行时,这在 Windows7 中也不起作用。
谁能告诉我如何检查服务是否通过 DLL 运行?
注意:DLL 由资源管理器加载。
I have registered a COM Context menu DLL (to display Explorer Context Menus) in a Windows7 machine. In the DLL, I have checked whether a service is running in my system. The service is running under 'Local System Account'.
I have checked the service status by OpenSCManager
and QueryServiceStatus
. It seems to work in XP without any issue. But in Windows7, sometimes I get 'Access Denied' error and some times I get the wrong result... (eg, Service is running but it shows status as service is stopped.) I am not sure how to check this in Windows7.
I have also checked whether my exe is running by
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, aProcesses[i]);
but this is also not working in Windows7 when I am running as Service.
Could anyone update me how to check whether the Service is running through DLL?
Note: The DLL is loaded by Explorer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会遇到 UAC (http://en.wikipedia.org/wiki/User_Account_Control ),这可能会限制您从非管理环境访问服务。当您以管理员身份运行资源管理器时,您的应用程序可以运行吗?
You may be running into the UAC (http://en.wikipedia.org/wiki/User_Account_Control), which may limit your access to services from a non-administrative context. Does your application work when you run Explorer as an Administrator?