Click here to Skip to main content
15,907,392 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to get processes even if their name changed? Pin
CPallini30-Jan-08 23:46
mveCPallini30-Jan-08 23:46 
GeneralRe: How to get processes even if their name changed? Pin
Luc Pattyn31-Jan-08 1:34
sitebuilderLuc Pattyn31-Jan-08 1:34 
GeneralRe: How to get processes even if their name changed? Pin
CPallini31-Jan-08 2:15
mveCPallini31-Jan-08 2:15 
GeneralRe: How to get processes even if their name changed? Pin
Luc Pattyn31-Jan-08 2:34
sitebuilderLuc Pattyn31-Jan-08 2:34 
GeneralOK, 241270 013 27 Pin
CPallini31-Jan-08 2:48
mveCPallini31-Jan-08 2:48 
GeneralRe: How to get processes even if their name changed? Pin
spearwall31-Jan-08 4:16
spearwall31-Jan-08 4:16 
GeneralRe: How to get processes even if their name changed? Pin
Luc Pattyn31-Jan-08 5:19
sitebuilderLuc Pattyn31-Jan-08 5:19 
GeneralRe: How to get processes even if their name changed? [modified] Pin
spearwall31-Jan-08 17:12
spearwall31-Jan-08 17:12 
thanksRose | [Rose]
all is about I want to check whether one process is running or not.
My check was not correct if someone renamed the EXE file which uses to open that process.

So I decide to check it out by comparing size of main module of each process are running and size the EXE file:
<br />
using System;<br />
using System.Diagnostics;<br />
using System.IO;<br />
<br />
...<br />
<br />
public Process[] getProcessesByExeSize()<br />
        {<br />
            Process[] myProcesses = null;<br />
            int i = -1;<br />
            Process[] allproc = Process.GetProcesses();<br />
            foreach (Process p in allproc)<br />
            {<br />
                string s = p.MainModule.FileName; //pass the Path of EXE file to s. s must be something like "D:\Soft\myexe.exe"<br />
                FileInfo finfo = new FileInfo(s); //I got error "Illegal characters in path" at this line. <br />
                long fileinbytes = finfo.Length;<br />
                if (fileinbytes == 12345) //12345 is size of EXE file <br />
                {<br />
                    myProcesses[i+1] = p;<br />
                    i++;<br />
                }                    <br />
            }<br />
            return myProcesses;<br />
        }<br />

I tried to replace "\" by "\\" or add @ in front of s but not success.

modified on Thursday, January 31, 2008 11:21:03 PM

GeneralRe: How to get processes even if their name changed? Pin
Luc Pattyn31-Jan-08 22:22
sitebuilderLuc Pattyn31-Jan-08 22:22 
GeneralRe-initialization of the graph Pin
B!Z30-Jan-08 21:28
B!Z30-Jan-08 21:28 
GeneralRe: Re-initialization of the graph Pin
pmarfleet30-Jan-08 21:45
pmarfleet30-Jan-08 21:45 
GeneralPage reloaded when ContentType = "Application/vnd.msword" [modified] Pin
JohnAneston30-Jan-08 20:41
JohnAneston30-Jan-08 20:41 
Questionhow to display the tree nodes and its atrributes in the list format in multiline textbox Pin
samidhas30-Jan-08 20:28
samidhas30-Jan-08 20:28 
GeneralCreating Custom Emails from C# code Pin
SB 30-Jan-08 20:03
SB 30-Jan-08 20:03 
GeneralRe: Creating Custom Emails from C# code Pin
Ed.Poore30-Jan-08 23:00
Ed.Poore30-Jan-08 23:00 
GeneralRegarding certification.... Pin
tasumisra30-Jan-08 19:01
tasumisra30-Jan-08 19:01 
GeneralWrong forum Pin
pmarfleet30-Jan-08 21:47
pmarfleet30-Jan-08 21:47 
GeneralConnecting C#.Net to SQL Server 2000 Pin
klaydze30-Jan-08 17:31
klaydze30-Jan-08 17:31 
GeneralRe: Connecting C#.Net to SQL Server 2000 Pin
Rocky#30-Jan-08 20:19
Rocky#30-Jan-08 20:19 
GeneralRe: Connecting C#.Net to SQL Server 2000 Pin
Ashfield31-Jan-08 0:06
Ashfield31-Jan-08 0:06 
GeneralCatching specialty keys from keyboard [modified] Pin
Jordanwb30-Jan-08 10:16
Jordanwb30-Jan-08 10:16 
GeneralRe: Catching specialty keys from keyboard Pin
DaveyM6930-Jan-08 10:43
professionalDaveyM6930-Jan-08 10:43 
GeneralRe: Catching specialty keys from keyboard Pin
Jordanwb30-Jan-08 10:54
Jordanwb30-Jan-08 10:54 
GeneralRe: Catching specialty keys from keyboard Pin
TJoe30-Jan-08 10:57
TJoe30-Jan-08 10:57 
GeneralRe: Catching specialty keys from keyboard Pin
Jordanwb30-Jan-08 11:32
Jordanwb30-Jan-08 11:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.