Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
GetAllProccess Function Return All Runing Proccesses In Windows. I want to get current proccess name which extension is ".avi", ".mkv", ".mpg", ".mp4", ".wmv"
e.g. if I play any video file in windows media player it return (wmplayer.exe) or if I play any video file in KM PLAYER it returns(kmplayer.exe)
Thanks
here is my code

this code working very slow reference

http://vmccontroller.codeplex.com/SourceControl/changeset/view/47386#195318[^]
C#
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 be correct. Was : Exit While
                    }
                }
            }
        }

[Edit]Code block added and made able that you can click on the link[/Edit]
Posted
Updated 12-Feb-13 1:25am
v2
Comments
Jibesh 12-Feb-13 5:39am    
Do you know ".avi", ".mkv", ".mpg", ".mp4", ".wmv" are just the file extensions and not the process extensions. Normally Process extensions are .exe only. what are you actually trying to do?
jimisd_axily 12-Feb-13 6:04am    
e.g. if I play any video file in windows media player it return (wmplayer.exe) or if I play any video file in KM PLAYER it returns(kmplayer.exe)

Hi jimisd_axily

The Process IS NOT the file is it running!
If you play a .wmv or a mp3 file with a player then the file you play is different than the process running it.

Sometimes you run a file which is the executable itself, like when you double click an EXE file.

Each file type (according to the extension) has an associated executable that knows (or is supposed to know) what do with it, as in the case of mp3 and the media player you have as a default.

Cheers,
Edo
 
Share this answer
 
v2
Finding and Listing Processes in C#[^]
This article has the things you are asking for. Read it and use these concept to build your app, happy coding!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900