Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C#3.0 C# C#4.0
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[^]
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 12-Feb-13 0:19am
Edited 12-Feb-13 2:25am
ProgramFOX149.7K
v2
Comments
Jibesh at 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 at 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)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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!
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 215
1 Sebastiaan Meijerink 141
2 Sergey Alexandrovich Kryukov 124
3 Rana Waqas 85
4 Maciej Los 84
0 Sergey Alexandrovich Kryukov 6,558
1 OriginalGriff 6,288
2 Peter Leow 2,534
3 Abhinav S 2,358
4 Maciej Los 2,352


Advertise | Privacy | Mobile
Web03 | 2.8.150414.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100