How to get "excutable" name in C# of a current process

  • Thread starter Thread starter Regis Melo
  • Start date Start date
R

Regis Melo

Hello,

I'm trying to get the "EXE" name of app that runs the current
window. To get the current window I use:

[ DllImport("user32.dll") ]
private static extern
int GetForegroundWindow();


const int nChars = 256;
int handle = 0;
StringBuilder Buff = new StringBuilder(nChars);

handle = GetForegroundWindow();
GetWindowText(handle, Buff, nChars)

return Buff.toString(); // Returns the title of
// current window


If this funcion returns "MSN Hotmail", for example, I want to get
"iexplorer.exe", indicating that the current window is "ieplorer.exe".

Thanks,

Regis
 
Hello,

I want to know the name o exe file of current process. Not the name of
my executable....

Tks,

Regis

Ayende said:
Assmebly.GetExecutingAssembly().Name


Hello,

I'm trying to get the "EXE" name of app that runs the current
window. To get the current window I use:

[ DllImport("user32.dll") ]
private static extern
int GetForegroundWindow();


const int nChars = 256;
int handle = 0;
StringBuilder Buff = new StringBuilder(nChars);

handle = GetForegroundWindow();
GetWindowText(handle, Buff, nChars)

return Buff.toString(); // Returns the title of
// current window


If this funcion returns "MSN Hotmail", for example, I want to get
"iexplorer.exe", indicating that the current window is "ieplorer.exe".

Thanks,

Regis
 
Regis Melo said:
I want to know the name o exe file of current process. Not the name of
my executable....

Have you tried looking through the Modules property of the result of
Process.GetCurrentProcess()?
 
Back
Top