我们如何找到正在运行的Windows服务的进程ID? [英] How can we find the process ID of a running Windows Service?

查看:614
本文介绍了我们如何找到正在运行的Windows服务的进程ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个好的方法来找到特定Windows服务的进程ID。

I'm looking for a good way to find the process ID of a particular Windows Service.

特别是,我需要找到默认的 WebClient服务。它在svchost.exe进程中作为本地服务托管。我看到,当我使用netstat看到什么进程使用什么端口列出[WebClient]在进程名称下,所以我希望有一些(相对)简单的机制来找到这个信息。

In particular, I need to find the pid of the default "WebClient" service that ships with Windows. It's hosted as a "local service" within a svchost.exe process. I see that when I use netstat to see what processes are using what ports it lists [WebClient] under the process name, so I'm hoping that there is some (relatively) simple mechanism to find this information.

推荐答案

QueryServiceStatusEx 返回 SERVICE_STATUS_PROCESS ,其中包含运行服务的进程的进程标识符。

QueryServiceStatusEx returns a SERVICE_STATUS_PROCESS, which contains the process identifier for the process under which the service is running.

您可以使用 OpenService 从其名称获取服务的句柄。

You can use OpenService to obtain a handle to a service from its name.

这篇关于我们如何找到正在运行的Windows服务的进程ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆