Atitit,通过pid获取进程文件路径 java php c#.net版本大总结
Atitit,通过pid获取进程文件路径 java php c#.net版本大总结
1.3. 第三种方法是使用Windows Vista新增的函数QueryFullProcessImageName,由于是Vista新增的,所以兼容性不好。2
2. 使用powershell 相等于调用System.Diagnostics.Process2
2.1. Get-Process -id 6712 -FileVersionInfo2
3. 获取加载的dll模块列表 Get-Process -id 6712 -Module3
1. 通过PID获取进程路径的几种方法
1.1. GetModuleFileNameEx
想获得进程可执行文件的路径最常用的方法是通过GetModuleFileNameEx函数获得可执行文件的模块路径这个函数从Windows NT 4.0开始到现在的Vista系统都能使用,向后兼容性比较好。
1.2. 第二种方法是GetProcessImageFileName函数,这个函数在Windows XP及其以后的系统中都能使用,使用此函数返回的路径不是通常的系统盘符,如"C:\...",而是驱动层的表示方式"\Device\HarddiskVolume1\...",所以使用起来不是很方便。
1.3. 第三种方法是使用Windows Vista新增的函数QueryFullProcessImageName,由于是Vista新增的,所以兼容性不好。
2. 使用powershell 相等于调用System.Diagnostics.Process
2.1. Get-Process -id 6712 -FileVersionInfo
PS C:\Windows\winsxs\amd64_microsoft-windows-gpowershell-exe_31bf3856ad364e35_6.1.7600.16385_none_94861149bb66249c> Get-Process -id 6712 -FileVersionInfo
ProductVersion FileVersion FileName
-------------- ----------- --------
C:\eclipse\eclipse.exe
2.1.1. -FileVersionInfo
获取进程中运行的程序的文件版本信息。
在 Windows Vista 以及更高版本的 Windows 上,必须使用“以管理员身份运行”选项打开 Windows PowerShell,才能对您不具有所有权的进程使用此参数。
使用此参数等效于获取每个进程对象的 MainModule.FileVersionInfo 属性。如果使用此参数,则 Get-Process 返回 FileVersionInfo 对象 (System.Diagnostics.FileVersionInfo),而非进程对象。因此,不能通过管道将命令输出传递到需要进程对象的 cmdlet(例如 Stop-Process)。
作者:: 绰号:老哇的爪子 ( 全名::Attilax akbar al rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙, EMAIL:1466519819@qq.com
2.2. C#.net版本
//根据名称获取进程
Process[] ps = Process.GetProcessesByName("NameStr");
foreach (Process p in ps)
{
//输出进程路径
Console.WriteLine(p.MainModule.FileName);
}
2.3. Note
需要先设置权限RemoteSigned前面有空格与set-ExecutionPolicy 隔开
set-ExecutionPolicy RemoteSigned
3. 获取加载的dll模块列表 Get-Process -id 6712 -Module
PS C:\Windows\winsxs\amd64_microsoft-windows-gpowershell-exe_31bf3856ad364e35_6.1.7600.16385_none_94861149bb66249c> Get-Process -id 6712 -Module
Size(K) ModuleName FileName
------- ---------- --------
316 eclipse.exe C:\eclipse\eclipse.exe
1700 ntdll.dll C:\Windows\SYSTEM32\ntdll.dll
1152 kernel32.dll C:\Windows\system32\kernel32.dll
432 KERNELBASE.dll C:\Windows\system32\KERNELBASE.dll
1000 USER32.dll C:\Windows\system32\USER32.dll
412 GDI32.dll C:\Windows\system32\GDI32.dll
56 LPK.dll C:\Windows\system32\LPK.dll
808 USP10.dll C:\Windows\system32\USP10.dll
636 msvcrt.dll C:\Windows\system32\msvcrt.dll
2000 COMCTL32.dll C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.18837_none_fa3b1e3d17594757\COMCTL32.dll
452 SHLWAPI.dll C:\Windows\system32\SHLWAPI.dll
184 IMM32.DLL C:\Windows\system32\IMM32.DLL
1060 MSCTF.dll C:\Windows\system32\MSCTF.dll
72 eclipse_1608.dll C:\eclipse\plugins\org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20150204-1316\eclipse_1608.dll
876 ADVAPI32.dll C:\Windows\system32\ADVAPI32.dll
124 sechost.dll C:\Windows\SYSTEM32\sechost.dll
1204 RPCRT4.dll C:\Windows\system32\RPCRT4.dll
48 VERSION.dll C:\Windows\system32\VERSION.dll
344 uxtheme.dll C:\Windows\system32\uxtheme.dll
2060 ole32.dll C:\Windows\system32\ole32.dll
60 CRYPTBASE.dll C:\Windows\system32\CRYPTBASE.dll
8552 jvm.dll C:\eclipse\jre\bin\server\jvm.dll
36 WSOCK32.dll C:\Windows\system32\WSOCK32.dll
308 WS2_32.dll C:\Windows\system32\WS2_32.dll
32 NSI.dll C:\Windows\system32\NSI.dll
236 WINMM.dll C:\Windows\system32\WINMM.dll
28 PSAPI.DLL C:\Windows\system32\PSAPI.DLL
840 MSVCR100.dll C:\Windows\system32\MSVCR100.dll
60 verify.dll C:\eclipse\jre\bin\verify.dll
160 java.dll C:\eclipse\jre\bin\java.dll
88 zip.dll C:\eclipse\jre\bin\zip.dll
13860 SHELL32.dll C:\Windows\system32\SHELL32.dll
60 profapi.dll C:\Windows\system32\profapi.dll
96 CRYPTSP.dll C:\Windows\system32\CRYPTSP.dll
284 rsaenh.dll C:\Windows\system32\rsaenh.dll
120 USERENV.dll C:\Windows\system32\USERENV.dll
104 net.dll C:\eclipse\jre\bin\net.dll
1036 AcSpi64.dll C:\Windows\system32\AcSpi64.dll
860 OLEAUT32.dll C:\Windows\system32\OLEAUT32.dll
68 WTSAPI32.dll C:\Windows\system32\WTSAPI32.dll
452 WINHTTP.dll C:\Windows\system32\WINHTTP.dll
400 webio.dll C:\Windows\system32\webio.dll
1200 PROPSYS.dll C:\Windows\system32\PROPSYS.dll
340 mswsock.dll C:\Windows\system32\mswsock.dll
28 wship6.dll C:\Windows\System32\wship6.dll
1884 SETUPAPI.dll C:\Windows\system32\SETUPAPI.dll
216 CFGMGR32.dll C:\Windows\system32\CFGMGR32.dll
104 DEVOBJ.dll C:\Windows\system32\DEVOBJ.dll
156 IPHLPAPI.DLL C:\Windows\system32\IPHLPAPI.DLL
44 WINNSI.DLL C:\Windows\system32\WINNSI.DLL
68 dhcpcsvc6.DLL C:\Windows\system32\dhcpcsvc6.DLL
96 dhcpcsvc.DLL C:\Windows\system32\dhcpcsvc.DLL
68 nio.dll C:\eclipse\jre\bin\nio.dll
84 NLAapi.dll C:\Windows\system32\NLAapi.dll
84 napinsp.dll C:\Windows\system32\napinsp.dll
100 pnrpnsp.dll C:\Windows\system32\pnrpnsp.dll
364 DNSAPI.dll C:\Windows\system32\DNSAPI.dll
44 winrnr.dll C:\Windows\System32\winrnr.dll
152 mdnsNSP.dll C:\Program Files\Bonjour\mdnsNSP.dll
28 wshtcpip.dll C:\Windows\System32\wshtcpip.dll
32 rasadhlp.dll C:\Windows\system32\rasadhlp.dll
332 fwpuclnt.dll C:\Windows\System32\fwpuclnt.dll
672 swt-win32-4430.dll C:\eclipse\configuration\org.eclipse.osgi\869\0\.cp\swt-win32-4430.dll
604 comdlg32.dll C:\Windows\system32\comdlg32.dll
452 WINSPOOL.DRV C:\Windows\system32\WINSPOOL.DRV
1388 WININET.dll C:\Windows\system32\WININET.dll
12 Normaliz.dll C:\Windows\system32\Normaliz.dll
2120 iertutil.dll C:\Windows\system32\iertutil.dll
1372 urlmon.dll C:\Windows\system32\urlmon.dll
1460 CRYPT32.dll C:\Windows\system32\CRYPT32.dll
60 MSASN1.dll C:\Windows\system32\MSASN1.dll
96 dwmapi.dll C:\Windows\system32\dwmapi.dll
612 CLBCatQ.DLL C:\Windows\system32\CLBCatQ.DLL
48 LINKINFO.dll C:\Windows\system32\LINKINFO.dll
120 swt-gdip-win32-4430.dll C:\eclipse\configuration\org.eclipse.osgi\869\0\.cp\swt-gdip-win32-4430.dll
2136 gdiplus.dll C:\Windows\WinSxS\amd64_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7601.19061_none_2b299db671e86e03\gdiplus.dll
1192 WindowsCodecs.dll C:\Windows\system32\WindowsCodecs.dll
72 localfile_1_0_0.dll C:\eclipse\configuration\org.eclipse.osgi\72\0\.cp\os\win32\x86_64\localfile_1_0_0.dll
68 jWinHttp-1.0.0.dll C:\eclipse\configuration\org.eclipse.osgi\75\0\.cp\jWinHttp-1.0.0.dll
336 oleacc.dll C:\Windows\system32\oleacc.dll
28 msimg32.dll C:\Windows\system32\msimg32.dll
236 mlang.dll C:\Windows\system32\mlang.dll
144 sunec.dll C:\eclipse\jre\bin\sunec.dll
80 RpcRtRemote.dll C:\Windows\system32\RpcRtRemote.dll
348 apphelp.dll C:\Windows\system32\apphelp.dll
1832 explorerframe.dll C:\Windows\system32\explorerframe.dll
268 DUser.dll C:\Windows\system32\DUser.dll
968 DUI70.dll C:\Windows\system32\DUI70.dll
180 ntmarta.dll C:\Windows\system32\ntmarta.dll
328 WLDAP32.dll C:\Windows\system32\WLDAP32.dll
512 ntshrui.dll C:\Windows\system32\ntshrui.dll
140 srvcli.dll C:\Windows\system32\srvcli.dll
60 cscapi.dll C:\Windows\system32\cscapi.dll
44 slc.dll C:\Windows\system32\slc.dll
48 netutils.dll C:\Windows\system32\netutils.dll
10704 ieframe.dll C:\Windows\System32\ieframe.dll
580 SXS.DLL C:\Windows\system32\SXS.DLL
44 Secur32.dll C:\Windows\system32\Secur32.dll
148 SSPICLI.DLL C:\Windows\system32\SSPICLI.DLL
17492 mshtml.dll C:\Windows\System32\mshtml.dll
56 msimtf.dll C:\Windows\system32\msimtf.dll
232 msls31.dll C:\Windows\system32\msls31.dll
904 d2d1.dll C:\Windows\system32\d2d1.dll
1532 DWrite.dll C:\Windows\system32\DWrite.dll
668 dxgi.dll C:\Windows\system32\dxgi.dll
236 WINTRUST.dll C:\Windows\system32\WINTRUST.dll
208 d3d10_1.dll C:\Windows\system32\d3d10_1.dll
340 d3d10_1core.dll C:\Windows\system32\d3d10_1core.dll
1856 D3D10Warp.dll C:\Windows\system32\D3D10Warp.dll
1268 d3d10.dll C:\Windows\system32\d3d10.dll
300 d3d10core.dll C:\Windows\system32\d3d10core.dll
4016 GOOGLEPINYIN2.IME C:\Windows\system32\GOOGLEPINYIN2.IME
1172 dbghelp.dll C:\Windows\system32\dbghelp.dll
136 bcrypt.dll C:\Windows\System32\bcrypt.dll
304 bcryptprimitives.dll C:\Windows\system32\bcryptprimitives.dll
152 360CloudShellExt64.dll C:\Program Files (x86)\360WangPan\CloudMini\360CloudShellExt64.dll
468 QMGCShellExt64.dll C:\Program Files (x86)\QQPCMgr\11.2.17063.223\QMGCShellExt64.dll
1060 MSVCP80.dll C:\Windows\WinSxS\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6229_none_88dcc0bf2fb1b808\MSVCP80.dll
804 MSVCR80.dll C:\Windows\WinSxS\amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.6229_none_88dcc0bf2fb1b808\MSVCR80.dll
664 exnscan64.dll C:\Program Files (x86)\QQPCMgr\11.2.17063.223\exnscan64.dll
88 NETAPI32.dll C:\Windows\system32\NETAPI32.dll
84 wkscli.dll C:\Windows\system32\wkscli.dll
212 EhStorShell.dll C:\Windows\system32\EhStorShell.dll
1428 jd-eclipse.dll C:\eclipse\configuration\org.eclipse.osgi\761\0\.cp\win32\x86_64\jd-eclipse.dll
652 MSVCR90.dll C:\Windows\WinSxS\amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.7523_none_08e1eaf5a83f8ea2\MSVCR90.dll
4. 参考
通过PID获取进程路径的几种方法 - 安静的主页.htm
paip. c++ 调用.net dll 最好方式powershell 使用总结. - attilax的专栏 - 博客频道 - CSDN.NET.htm
Atitit,通过pid获取进程文件路径 java php c#.net版本大总结的更多相关文章
- 通过PID获取进程路径的几种方法
通过PID获取进程路径的几种方法 想获得进程可执行文件的路径最常用的方法是通过GetModuleFileNameEx函数获得可执行文件的模块路径这个函数从Windows NT 4.0开始到现在的Vis ...
- java获取classpath文件路径空格转变成了转义字符%20的问题
java获取classpath文件路径空格转变成了转义字符%20的问题 这个问题很纠结,服务器的文件路径带有空格,空格被转化是%20了,悲剧就出现了 下面展示一段代码String path = get ...
- delphi根据进程PID获取程序所在路径的函数(用OpenProcess取得句柄,用GetModuleFileNameEx取得程序名)
uses psapi; {根据进程PID获取程序所在路径的函数}function GetProcessExePath(PID: Cardinal): string;varpHandle: THandl ...
- java基础知识3--如何获取资源文件(Java中获取资源文件的url)
java开发中,常见的resource文件有:.xml,.properties,.txt文件等,后台开发中经常用到读取资源文件,处理业务逻辑,然后返回结果. 获取资源文件的方法说明getResourc ...
- Windows获取进程完整路径
#include <stdio.h> #include <locale.h> #include <windows.h> #include <tlhelp32. ...
- Atitit onvif协议获取rtsp地址播放java语言 attilx总结
Atitit onvif协议获取rtsp地址播放java语言 attilx总结 1.1. 获取rtsp地址的算法与流程1 1.2. Onvif摄像头的发现,ws的发现机制,使用xcf类库1 2. 调用 ...
- 如何获取启动文件路径 GetModuleFileName
如何获取启动文件路径 GetModuleFileName CString GetExeDirPath() { }; CString strExeDirPath; GetModuleFileName(N ...
- python获取当前文件路径
python获取当前文件路径 学习了:https://www.cnblogs.com/strongYaYa/p/7200357.html https://blog.csdn.net/heatdeath ...
- Application.StartupPath获取执行文件路径substring()取特定长度字符串取得根目录
Application.StartupPath获取执行文件路径substring()取特定长度字符串取得根目录 2012-07-20 10:48 257人阅读 评论(0) 收藏 举报 path usi ...
随机推荐
- 位运算和enum中的位运算
1.位逻辑非运算 ~ 位逻辑非运算是单目的,只有一个运算对象.位逻辑非运算按位对运算对象的值进行非运算,即:如果某一位等于0,就将其转变为1:如果某一位等于1,就将其转变为0. 比如,对二进制的100 ...
- 【树上莫队】bzoj3757 苹果树
学习这位神犇的:http://blog.csdn.net/jiangyuze831/article/details/41476865 注意: ①排序时第一关键字是左端点所在块编号(块状树),第二关键字 ...
- 3.2常用类(java学习笔记)String与StringBuffer
一.String String又称不可变字符序列. 我们看JDK源码中用于字符存储的数组有final修饰,final修饰变量就代表变量不能改变. 我们可以看API文档中对String的描述. Stri ...
- [转] matlab调用opencv函数的配置
原文地址百度账户 aleasa123 方式1 1. 首先保证vs2010能正确调用opencv函数, 2. Matlab中选择编译器,操作如下: 打开matlab2012,输入mex –setup ...
- vue中的组件,Component元素,自定义路由,异步数据获取
组件是Vue最强大的功能之一.组件是一组可被复用的具有一定功能,独立的完整的代码片段,这个代码片段可以渲染一个完整视图结构组件开发如何注册组件?第一步,在页面HTML标签中使用这个组件名称,像使用DO ...
- C#之Hello World(入门 )
C#是一种简单.现代.面向对象和类型安全的编程语言. C#由C和C++发展而来.C#(英文发音C sharp)牢固地植根于C和C++语言族谱中,是Microsoft专门为使用.NET平台而创建的. • ...
- iOS:GitHub上值得关注的iOS开源项目
1.AFNetworking地址:https://github.com/AFNetworking/AFNetworking用于网络请求 2.JSONKit地址:https://github.com/j ...
- Makefile的制作
一个工程中的源文件不计其数,其按类型.功能.模块分别放在若干个目录中,makefile定义系列的规则来指定,哪些文件需要先编译,哪些文件需要后编译,哪些文件需要重新编译,甚至于进行更复杂的功能操作,因 ...
- elasticsearch中的filter与aggs
今天在ES上做了一个聚合,先过滤一个嵌套对象,再对另一个域做聚合,但是过滤似乎没有起作用 { "size":0, "filter":{ "nested ...
- Mac机装Win7后 启动只见鼠标怎么办
我有一台Mac机,用Bootcamp的方式装了Win7,昨天一按开机键发现只有鼠标没有别的. 当时按热启动无效,把笔记本盖子合上一会再开也无效,按关机键关掉再开也无效(这时是短按). 当时想是不是Ma ...