Click to See Complete Forum and Search --> : Accessing an applications executable path...


Mahanthi
May 5th, 1999, 02:30 PM
I want to know how to programmatically get hold of the Path of the MFC program i have written. I can get access to the current application name, but i want the entire path of the executable.

What i want to achieve is that, when a user run my application, i want to know the entire path from where the application is being launched. Tried the variable present in the CWinApp class, but not able to get the Path. Tried looking in Win32 API, but still couldn't converge on one if present.


Any suggestions ?
Thanx
Mahanthi



mahanthi@rocketmail.com

Paul McKenzie
May 5th, 1999, 05:16 PM
Try GetModuleFileName()

Regards,

Paul McKenzie

Steven Roelants
May 6th, 1999, 03:47 AM
try using the string:

_pgmptr

this will give you the application path

Hope this helps,

Steven

Craig Pittaway
May 6th, 1999, 04:34 AM
Try using the following function call:

GetCurrentDirectory (sizeof (g_aEXELocation),
g_aEXELocation);


Hope this helps.

Mahanthi
May 6th, 1999, 09:52 AM
Hi,
Thanks, it was helpful. It did work and this was the function i was looking for.

Thanks once again.
Mahanthi


mahanthi@rocketmail.com

scp
May 6th, 1999, 10:34 AM
GetCurrentDirectory () will not give you the application exe path if you have a different Start-in directory.

You should use GetModuleFileName() as follows:

char chExePath[_MAX_PATH];
GetModuleFileName(GetModuleHandle(NULL), chExePath, _MAX_PATH);

HTH

ilgar
May 10th, 1999, 09:19 AM
Guys,

Just call GetCommandLine() function

and you'll receive full path to .exe name and all parameters.

Thanks,
Ilgar Mashayev