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 ...
随机推荐
- c++ primer敲代码第二章
今天越来越发现 学习一门编程语言,没有大量的code实践是不行的.看得快忘得更快.痛下决心,把primer的code习题一一实现. 习题2.11 底数和指数,求结果 #include <iost ...
- linux 处理两个文件的并集,交集,计数
1. 取出两个文件的并集(重复的行只保留一份) cat file1 file2 | sort | uniq 2. 取出两个文件的交集(只留下同时存在于两个文件中的文件) cat file1 file2 ...
- 关于scanf函数的返回值问题
如: scanf("%d%d",&a,&b); 1.如果a和b都被成功读入,则scanf的返回值为2 2.如果只有a被成功读入,那么返回值为1 3.如果a和b都未被 ...
- python 爬取36K新闻
代码如下: from urllib import request url = 'http://36kr.com/api/info-flow/newsflash_columns/newsflashes? ...
- /etc/sudoer文件配置简析
参考: http://blog.chinaunix.net/uid-26642180-id-3962245.html # User privilege specification root AL ...
- 【Git】GitHub for Windows使用(3) GitHub Flow的使用
第三章了,关于GitHub上有一个Pull Request,是展示本项目或资源所有的Pull 请求的. 而这个开发流程是基于GitHub Flow的开发模式. 网上关于GitHub Flow简单的介绍 ...
- 利用LogParser分析IIS日志
LogParser是微软官方出品的用于读取分析IIS日志的工具,使用类SQL语句过滤文本日志内容,并可将内容导出到csv.sqlserver作进一步分析 下载地址:http://www.micr ...
- VisualSVN设置提交时必须输入log信息
在别人的基础上修改的: 自己在Windows上用VisualSVN搭了个服务器,默认提交代码是可以不填任何信息,这可不是我所期望的,于是找到了下面的解决方案: 在VisualSVN的管理控制台中可以设 ...
- Android Studio生成APK自动追加版本号、自定义apk名称、指定签名证书文件
你也可以查看我的其他同类文章,也会让你有一定的收货! 生成APK自动追加版本号 可自动区分debug和release,并追加版本号: 打开 build.gradle 在 android 节点中插入下面 ...
- GDUT决赛题解
决赛,我自我认为题目难度更大,反而我的心态更好了. 由于放轻松的时候反而效果更好,跟昨天的观点一样,凡是可以1A的,才算这题做得好. A.数目不大,关键是看懂题(我自己连输入输出是什么都不清楚.... ...