get current process name with file extension in c#


getallproccess function return runing proccesses in windows. want current proccess name extension ".avi", ".mkv", ".mpg", ".mp4", ".wmv"
e.g. if play video file in windows media player return (wmplayer.exe) or if play video file in km player returns(kmplayer.exe)
thanks
here code
 
code working slow reference 
 
http://vmccontroller.codeplex.com/sourcecontrol/changeset/view/47386#195318
 
string filename; process[] procs = process.getprocesses() ; foreach (process prc in procs) {
 
if (procs.length > 0)
{
int id = prc.id;
ienumerator<filesysteminfo> fie = detectopenfiles.getopenfilesenumerator(id);
 
while (fie.movenext())
{
if (fie.current.extension.tolower(cultureinfo.invariantculture) == ".mp3")
{
filename = fie.current.fullname;
break; // todo: might not correct. : exit while
}
}
}
}</filesysteminfo>

hi,

this expected process "context" running executable file regardless of data files opened process...

knowing trying (what wiht info ?)

see if tool such as http://technet.microsoft.com/en-us/sysinternals/bb896655 shows need. have low level api (this tool seems based on "object management" api) that allows list opened files (or wmi maybe)

so link gave seems use object management api. not sure how used it. if tried list files each process perhaps list files , keep in interested in case quicker...

or else please explicit issue (is issue looking @ processes rather files returned detectopenfiles ? understanding output .exe files, variable them ?) 


please mark whatever response solved issue thread marked "answered".





Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'