Name of files opened by a process in window?

橙三吉。 提交于 2019-11-28 13:24:11
Rahul Gautam

Here is the platform independent solution in python.

   import psutil
   p = psutil.Process(os.getpid()) # or PID of process
   p.open_files()

So i refer you psutil package it has too good functions for getting information on running processes

Here's a way to get a filename from pid using the Win32 API:

import win32api, win32con, win32process

handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, False, pid) #get handle for the pid
filename = win32process.GetModuleFileNameEx(handle, 0) #get exe path & filename for handle

This works on windows only (obviously).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!