获得进程名进程ID [英] get a process id from process name

查看:129
本文介绍了获得进程名进程ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我试图做使用Windows API在C语言中的一个项目。在我的项目的小部分得到的Lsass.exe进程ID。

Hi i am trying to do a project using windows API in C language. The small part in my project is to get process ID of lsass.exe.

我曾尝试下面的程序,但它不会工作。
我已阅读有关CreateToolhelp32Snapshot,Process32First,Process32Next功能,任何人都可以帮我解释如何在code使用它们。

i have tried the program below but it wont work. i have read about the CreateToolhelp32Snapshot, Process32First, Process32Next functions can anyone help me explaining how to use them in the code.

所以,请帮助我。
我是一个初学者到Windows API,所以我将AP preciate它,如果任何人都可以建议我一个很好的电子书来指代。

So please help me. i am a beginner to windows API so i will appreciate it if anyone can suggest me an good ebook to refer.

推荐答案

由于有可能是运行的进程名称的几个实例,有一个过程的图像名称和一个PID之间没有一对一的关系。你必须枚举进程,并检查基本模块的名称为每一个作为布尔戈斯介绍,通过使用EnumProcesses。

Because there might be several instances of a process name running, there is no one-to-one correlation between a process's image name and a PID. You'll have to enumerate the processes and check the base module names for each one as Burgos describes, by using EnumProcesses.

FWIW,净通过提供GetProcessesByName API,它返回的过程对象的集合处理这个问题。没多大用的,你当然是: - (

FWIW, .Net approaches this problem by providing the GetProcessesByName API, which returns a collection of process objects. Not much use to you of course :-(

这篇关于获得进程名进程ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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