开发者

Windows: Getting the version of a running process

开发者 https://www.devze.com 2023-02-15 22:33 出处:网络
I want to get an overview of all the programs that are being used and how many versions o开发者_如何学Pythonf this software that is being used. I do not need to know the exact version number (though i

I want to get an overview of all the programs that are being used and how many versions o开发者_如何学Pythonf this software that is being used. I do not need to know the exact version number (though it would be nice), just be able to say that two things are distinct versions (or builds).

Because I do not know anything about each program, I need this to be done in a generic way. How could this be done?


This is quite a general question, so I'll give you a general answer. You are going to need to do the following:

  • Enumerate all the processes by calling EnumProcesses().
  • For each process ID, OpenProcess() to obtain a process handle.
  • With each process handle call GetModuleFileNameEx() to obtain the process's main executable file name.
  • Finally call GetFileVersionInfo() and perhaps some of its friends to retrieve the information.

This will give you binary version information rather than marketing versions. For example Windows XP is version 5.1, Windows Vista is 6.0, Windows 7 is version 6.1. If you need marketing versions then that's probably not achievable in a general manner.

0

精彩评论

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

关注公众号