VBA 使用GetObject(“WinMgmts:“)取得系统所有进程名
vba代码如下
1 Sub DisplayAllProcess() 2 3 Dim objs, obj 4 5 Set objs = GetObject("WinMgmts:").InstancesOf("Win32_Process") 6 7 For Each obj In objs 8 Debug.Print obj.Description 9 Next 10 11 End Sub
执行结果:
System Idle Process System smss.exe csrss.exe wininit.exe ShellExperienceHost.exe RuntimeBroker.exe SogouImeBroker.exe RtkNGUI64.exe dllhost.exe EXCEL.EXE chrome.exe ONENOTE.EXE