|
-
April 9th, 1999, 11:45 AM
#1
Executable Path
Can anybody tell me a good way to find the path of my executable? For example, if my program is located in D:\Manager\Manager\Debug\, is there a way to return the path name? I've looked through the documentation on the MSDN CD, and didn't find much. Thanks in advance.
-
April 9th, 1999, 12:10 PM
#2
Re: Executable Path
A maybe acceptable solution I can shortly think of is ::GetCurrentDirectory(..),
but I guess this isn't 100 percent 
-
April 9th, 1999, 12:22 PM
#3
Re: Executable Path
The problem with GetCurrentDirectory is that when one creates a shortcut
it is possible to start the executable in a directory other than where it resides.
GetModuleFileName should be able to do what you need.
-
April 9th, 1999, 12:29 PM
#4
Re: Executable Path
Use GetCommandLine() to retrieve the entire path for the program. But I found out that the string returned by the GetCommandLine() acts a little different:
If the program runs along, you will get the path, e.g.: "C:\Programs\Debug\myprog.exe" has extra '"' wrap the path. I guess the Win32 API wants to be able to display long directory names.
If the program is launched by other program, the path won't have the extra '"'.
You can try both cases to see the differences and watch out the '"'. Hope this will help. Good luck.
Someone corrects me, if I am wrong.
Allen
-
April 9th, 1999, 12:29 PM
#5
Re: Executable Path
Hi!
Ofcourse you're right, that's what I ment with not 100 percent 
Thanks,
Thomas
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|