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 11-Feb-13 23:19pm
Edited 12-Feb-13 1:25am
ProgramFOX122.8K
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 Sergey Alexandrovich Kryukov 598
1 OriginalGriff 235
2 George Jonsson 230
3 CPallini 210
4 PIEBALDconsult 150
0 OriginalGriff 5,835
1 Sergey Alexandrovich Kryukov 5,263
2 CPallini 4,750
3 George Jonsson 3,227
4 Gihan Liyanage 2,487


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2014
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