Atitit,通过pid获取进程文件路径 java php  c#.net版本大总结

1. 通过PID获取进程路径的几种方法2

1.1. GetModuleFileNameEx 想获得进程可执行文件的路径最常用的方法是通过GetModuleFileNameEx函数获得可执行文件的模块路径这个函数从Windows NT 4.0开始到现在的Vista系统都能使用,向后兼容性比较好。2

1.2. 第二种方法是GetProcessImageFileName函数,这个函数在Windows XP及其以后的系统中都能使用,使用此函数返回的路径不是通常的系统盘符,如"C:\...",而是驱动层的表示方式"\Device\HarddiskVolume1\...",所以使用起来不是很方便。2

1.3. 第三种方法是使用Windows Vista新增的函数QueryFullProcessImageName,由于是Vista新增的,所以兼容性不好。2

2. 使用powershell  相等于调用System.Diagnostics.Process2

2.1. Get-Process -id 6712 -FileVersionInfo2

2.1.1. -FileVersionInfo3

2.2. C#.net版本3

2.3. Note3

3. 获取加载的dll模块列表    Get-Process -id 6712 -Module3

4. 参考10

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版本大总结的更多相关文章

  1. 通过PID获取进程路径的几种方法

    通过PID获取进程路径的几种方法 想获得进程可执行文件的路径最常用的方法是通过GetModuleFileNameEx函数获得可执行文件的模块路径这个函数从Windows NT 4.0开始到现在的Vis ...

  2. java获取classpath文件路径空格转变成了转义字符%20的问题

    java获取classpath文件路径空格转变成了转义字符%20的问题 这个问题很纠结,服务器的文件路径带有空格,空格被转化是%20了,悲剧就出现了 下面展示一段代码String path = get ...

  3. delphi根据进程PID获取程序所在路径的函数(用OpenProcess取得句柄,用GetModuleFileNameEx取得程序名)

    uses psapi; {根据进程PID获取程序所在路径的函数}function GetProcessExePath(PID: Cardinal): string;varpHandle: THandl ...

  4. java基础知识3--如何获取资源文件(Java中获取资源文件的url)

    java开发中,常见的resource文件有:.xml,.properties,.txt文件等,后台开发中经常用到读取资源文件,处理业务逻辑,然后返回结果. 获取资源文件的方法说明getResourc ...

  5. Windows获取进程完整路径

    #include <stdio.h> #include <locale.h> #include <windows.h> #include <tlhelp32. ...

  6. Atitit onvif协议获取rtsp地址播放java语言 attilx总结

    Atitit onvif协议获取rtsp地址播放java语言 attilx总结 1.1. 获取rtsp地址的算法与流程1 1.2. Onvif摄像头的发现,ws的发现机制,使用xcf类库1 2. 调用 ...

  7. 如何获取启动文件路径 GetModuleFileName

    如何获取启动文件路径 GetModuleFileName CString GetExeDirPath() { }; CString strExeDirPath; GetModuleFileName(N ...

  8. python获取当前文件路径

    python获取当前文件路径 学习了:https://www.cnblogs.com/strongYaYa/p/7200357.html https://blog.csdn.net/heatdeath ...

  9. Application.StartupPath获取执行文件路径substring()取特定长度字符串取得根目录

    Application.StartupPath获取执行文件路径substring()取特定长度字符串取得根目录 2012-07-20 10:48 257人阅读 评论(0) 收藏 举报 path usi ...

随机推荐

  1. disabling IPv6 name/address support: Address family not supported by protocol

    禁用IPv6 后影响邮件发送设置 vim /etc/postfix/main.cf # Enable IPv4, and IPv6 if supported inet_protocols = all

  2. JAVA net 笔记

    1.InetAddress 获取主机ip等 2.URL 3.URLConnection (url.openConnection() 创建对象) 4.BufferedReader 5.InputStre ...

  3. 【权值分块】bzoj3570 DZY Loves Physics I

    以下部分来自:http://www.cnblogs.com/zhuohan123/p/3726306.html 此证明有误. DZY系列. 这题首先是几个性质: 1.所有球质量相同,碰撞直接交换速度, ...

  4. [TC-FindingFriends]Finding Friends

    题目大意: 给定一个长度为$n(n\le10^5)$的数列$A(A_i\le10^9)$,求最小的$k$满足存在一个长度至少为$m(m\le n)$的子串,对于串中的每一个数$A_i$,都至少存在一个 ...

  5. Postman Json测试接口

    当传递Json数据时: 1.必须添加http头:content-type:application/json,否则会报错(后台取不到相对应的值) 注意:如果服务端只支持UTF-8,但程序未对提交数据进行 ...

  6. Java高级架构师(一)第30节:把应用部署到Linux服务器上

  7. Java高级架构师(一)第12节:Service的实现以及模块化

    BaseService.java package com.sishuok.architecture1.common.service; import java.util.List; import com ...

  8. 在energia中添加新的库

    很多时候energia提供的库不能够满足我们的需要,这个时候我们就要自己添加库到energia中.方法如下: 在energia目录下找到hardware目录 选择对应的单片机型号文件夹进入 进入lib ...

  9. Android之startActivityForResult

    作用:当aAty跳转之bAty时,需要bAty回传数据,使用startActivityForResult. 相关的函数: aAty:--跳转至bAty(intent可以传递数据) void andro ...

  10. NHibernate官方文档中文版--只读实体类型(Read-only entities)

    重点 NHIbernate处理只读对象的方式可能和你在别处看到的不同.不正确的使用方式可能造成不可预料的结果. 当一个实体是只读的时候: NHIbernate不会对实体的简单属性和单向关联数据检查数据 ...