擅长:python、mysql、java
<p>谢谢你的回复。虽然您的解决方案更适合多平台支持,但这是我使用的解决方案,因为我只运行Windows8.1。在</p>
<pre><code> from win32com.client import GetObject
Wmi = GetObject('winmgmts:')
processes = Wmi.InstancesOf('Win32_Process')
# Get the Explorer process
explorer = Wmi.ExecQuery('select * from Win32_Process where Name="explorer.exe"')
# Grab its Pid
processId = explorer[0].Properties_('ProcessId').Value
</code></pre>