Getting the path of an exe correction

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

A small correction in my questio
Here i know the exe name. I want to find out abs path of the exe
How to do tha
Saty
 
Satya,

You could use the SearchPath API as suggested by using platform
invoke. The following example shows how to find where notepad.exe
it located

public class Win32
{
private Win32()
{
}

[DllImport("kernel32.dll")]
public static extern uint SearchPath(string path,
string fileName, string extension, uint bufferLength,
StringBuilder buffer, out string filePart);
}

Then all you need to do it call the method and pass the desired parameters
such as

string part;
StringBuilder buffer = new StringBuilder(512);
uint output = Class1.SearchPath(null, "notepad.exe", null,
(uint)buffer.Capacity, buffer, out part);
if( output != 0 )
Console.WriteLine(buffer.ToString());
Console.ReadLine();



Hope this helps,

//Andreas


Satya said:
A small correction in my question

Here i know the exe name. I want to find out abs path of the exe.
 
Back
Top