开发者

Check Service is running from a DLL

开发者 https://www.devze.com 2023-01-10 00:46 出处:网络
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 \

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开发者_JAVA技巧_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.


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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号