using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; using System.Collections; namespace ICompare测试 { class Program { static void Main(string[] args) { Process[] allprocess = Process.GetProcesses();//所有运行的进程 SortByProcessName cmpproname=new SortByProcessName(); SortByModuleName cmpmodulename=new SortByModuleName(); Array.Sort(allprocess, cmpproname); foreach (Process p in allprocess) { Console.WriteLine("{0}", p.ProcessName); try { ProcessModuleCollection allmodules = p.Modules;//进程下的所有模块 ProcessModule[] modules = new ProcessModule[allmodules.Count]; int i = 0; foreach (ProcessModule m in allmodules) { modules.SetValue(m, i++); } Array.Sort(modules, cmpmodulename); foreach (ProcessModule m in modules) { try { Console.WriteLine(" {0}", m.ModuleName); } catch { continue; } } } catch { } } } } public class SortByProcessName : IComparer//Array.Sort()要用到的参数 { public int Compare(object x, object y) { Process a = (Process)x; Process b = (Process)y; return a.ProcessName.CompareTo(b.ProcessName); } } public class SortByModuleName : IComparer { public int Compare(object x, object y) { ProcessModule a = (ProcessModule)x; ProcessModule b = (ProcessModule)y; return a.ModuleName.CompareTo(b.ModuleName); } } }
结果:
MSIMG32.dll
msvcrt.dll
MSVFW32.dll
MSWSOCK.dll
ncrypt.dll
NETAPI32.dll
netutils.dll
npmproxy.dll
NSI.dll
ntdll.dll
ntmarta.dll
ole32.dll
OLEAUT32.dll
POWRPROF.dll
profapi.dll
propsys.dll
PSAPI.DLL
RICHED20.DLL
RPCRT4.dll
RpcRtRemote.dll
rsaenh.dll
safemon.dll
SAMCLI.DLL
sechost.dll
Secur32.dll
SensApi.dll
SETUPAPI.dll
SHELL32.dll
SHLWAPI.dll
slc.dll
srvcli.dll
SspiCli.dll
TeamViewer.exe
TeamViewer_Resource_zhCN.dll
TeamViewer_StaticRes.dll
tv_w32.dll
urlmon.dll
USER32.dll
USERENV.dll
USP10.dll
uxtheme.dll
VERSION.dll
wdmaud.drv
webio.dll
winhttp.dll
WININET.dll
WINMM.dll
WINNSI.DLL
winsta.dll
WINTRUST.dll
wkscli.dll
WLDAP32.dll
WS2_32.dll
wshtcpip.dll
WTSAPI32.dll
TeamViewer_Service
ADVAPI32.dll
apphelp.dll
bcrypt.dll
bcryptprimitives.dll
browcli.dll
CFGMGR32.dll
CLBCatQ.DLL
comctl32.dll
CRYPT32.dll
CRYPTBASE.dll
CRYPTSP.dll
cscapi.dll
d3d8thk.dll
d3d9.dll
davclnt.dll
DAVHLPR.dll
DEVOBJ.dll
dhcpcsvc.DLL
DNSAPI.dll
drprov.dll
dwmapi.dll
fastprox.dll
fwpuclnt.dll
GDI32.dll
gdiplus.dll
GPAPI.dll
iertutil.dll
imagehlp.dll
IMM32.DLL
IPHLPAPI.DLL
kernel32.dll
KERNELBASE.dll
LPK.dll
Magnification.dll
MPR.dll
MSASN1.dll
MSCTF.dll
msvcrt.dll
MSWSOCK.dll
napinsp.dll
ncrypt.dll
Netapi32.dll
netprofm.dll
netutils.dll
NLAapi.dll
Normaliz.dll
npmproxy.dll
NSI.dll
ntdll.dll
NTDSAPI.dll
ntlanman.dll
ntmarta.dll
ole32.dll
OLEAUT32.dll
pnrpnsp.dll
profapi.dll
propsys.dll
Psapi.dll
rasadhlp.dll
RASAPI32.dll
rasman.dll
RPCRT4.dll
RpcRtRemote.dll
rsaenh.dll
rtutils.dll
sechost.dll
Secur32.dll
SensApi.dll
SETUPAPI.dll
SHELL32.dll
SHLWAPI.dll
srvcli.dll
SspiCli.dll
SXS.DLL
TeamViewer_Service.exe
urlmon.dll
USER32.dll
USERENV.dll
USP10.dll
uxtheme.dll
VERSION.dll
wbemcomn.dll
wbemprox.dll
wbemsvc.dll
WININET.dll
WINNSI.DLL
winrnr.dll
winsta.dll
WINTRUST.dll
wkscli.dll
WLDAP32.dll
WS2_32.dll
wshbth.dll
wship6.dll
wshtcpip.dll
WTSAPI32.dll
TSVNCache
tv_w32
ADVAPI32.dll
CFGMGR32.dll
COMCTL32.dll
CRTDLL.dll
CRYPTBASE.dll
DEVOBJ.dll
devrtl.DLL
GDI32.dll
IMM32.DLL
kernel32.dll
KERNELBASE.dll
LPK.dll
MSCTF.dll
msvcrt.dll
newdev.dll
ntdll.dll
ole32.dll
OLEAUT32.dll
RPCRT4.dll
sechost.dll
setupapi.dll
SHELL32.dll
SHLWAPI.dll
SspiCli.dll
tv_w32.dll
tv_w32.exe
USER32.dll
USP10.dll
UxTheme.dll
tv_x64
TXPlatform
ADVAPI32.dll
CLBCatQ.DLL
COMCTL32.dll
CRTDLL.dll
CRYPT32.dll
CRYPTBASE.dll
CRYPTSP.dll
GDI32.dll
iertutil.dll
IMM32.DLL
kernel32.dll
KERNELBASE.dll
LPK.dll
MSASN1.dll
MSCTF.dll
msvcrt.dll
NSI.dll
ntdll.dll
ole32.dll
OLEAUT32.dll
PSAPI.DLL
RPCRT4.dll
RpcRtRemote.dll
rsaenh.dll
safemon.dll
sechost.dll
SHELL32.dll
SHLWAPI.dll
SspiCli.dll
SXS.DLL
tv_w32.dll
TXPFProxy.dll
TXPlatform.exe
urlmon.dll
USER32.dll
USP10.dll
uxtheme.dll
VERSION.dll
WININET.dll
WINTRUST.dll
WS2_32.dll
wininit
winlogon
ZhuDongFangYu
360base.dll
360conf.dll
360leakfixplugin.dll
360NetBase.dll
360SoftMgrS.dll
ADVAPI32.dll
apphelp.dll
CFGMGR32.dll
CLBCatQ.DLL
cloudcom2.dll
COMCTL32.dll
CRYPT32.dll
CRYPTBASE.dll
DEVOBJ.dll
dhcpcsvc.DLL
dhcpcsvc6.DLL
DNSAPI.dll
fltlib.dll
GDI32.dll
heavygate.dll
iertutil.dll
IMM32.DLL
IPHLPAPI.DLL
kernel32.dll
KERNELBASE.dll
LINKINFO.dll
LPK.dll
MSASN1.dll
MSCTF.dll
mstask.dll
msvcrt.dll
mswsock.dll
NETAPI32.dll
netutils.dll
NSI.dll
ntdll.dll
ole32.dll
OLEAUT32.dll
profapi.dll
propsys.dll
PSAPI.DLL
qutmload.dll
RASAPI32.dll
rasman.dll
RPCRT4.dll
RpcRtRemote.dll
rtutils.dll
SAMCLI.DLL
SAMLIB.dll
sechost.dll
secur32.dll
SETUPAPI.dll
SHELL32.dll
SHLWAPI.dll
srvcli.dll
SspiCli.dll
taskschd.dll
urlmon.dll
USER32.dll
USERENV.dll
USP10.dll
VERSION.dll
WININET.dll
WINMM.dll
WINNSI.DLL
WINTRUST.dll
wkscli.dll
WS2_32.dll
WTSAPI32.dll
zhudongfangyu.exe
请按任意键继续. . .