|
-
April 6th, 1999, 05:48 AM
#1
[RESOLVED] Application's directory
I've used the following to get my dialogs application directory:
CString gPath;
GetModuleFileName(NULL, gPath.GetBuffer(_MAX_PATH), _MAX_PATH);
gPath.ReleaseBuffer();
gPath = gPath.Left(gPath.ReverseFind('\\') + 1);
Is this the best way?
-
April 6th, 1999, 07:32 AM
#2
Re: Application's directory
Hi! Andrew. It's me again.
I am not sure what exact U want to do.
But if ur want to find the directory
of ur app. How about GetCurrentDrectory()?
Good luck with your Work! 
Walter
-
April 6th, 1999, 07:36 AM
#3
Re: Misspell
Sorry for misspelling!
It's GetCurrentDirectory()!!!

Walter
-
April 6th, 1999, 07:40 AM
#4
Re: Misspell
Yes, but surely, isn't it possible that a user may adjust the "start up directory" of their short-cut which would change the current directory from that of where the program actually resides?
-
April 6th, 1999, 08:36 AM
#5
Re: Misspell
Hi Walter
I tried GetCurrentDirectory()
It returned c:\video instead of c:\video\debug which is where the exe is.
-
April 6th, 1999, 10:24 AM
#6
Re: Misspell
Did you run your App from VC IDE or
your App?
As I try if U ran ur App in VC IDE,
it chopps \debug. But if run from ur
App, I believe it will show full path.
Try again if U didn't.

Walter
-
April 8th, 1999, 01:59 AM
#7
Re: Misspell
Hi Walter
I think you are right.
I've ended up not using this code anyway since I've added the AVI file as a resource.
But atleast I know the principle of how to get the directory. But, suppose someone modifies the properties of a short-cut to the program where they change the "startup directory", will it still return the programs location?
Regards
-
April 8th, 1999, 03:42 AM
#8
Re: Misspell
Hi Andrew,
GetCurrentDirectory will always return the current directory, as the name says. This means, if someone sets the working directory to another dir, it will return this. Or if you use the common file dialog, it will change the current directory by default.
Your first attempt with GetModuleFileName was correct.
Martin
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
|