检查服务是否从 DLL 运行

发布于 2024-09-11 17:21:09 字数 525 浏览 1 评论 0原文

我已经在 Windows7 计算机中注册了 COM 上下文菜单 DLL(以显示资源管理器上下文菜单)。在DLL中,我检查了系统中是否有服务正在运行。该服务在“本地系统帐户”下运行。

我已通过 OpenSCManagerQueryServiceStatus 检查了服务状态。看来在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无戏配角 2024-09-18 17:21:09

您可能会遇到 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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文