|
-
Oct 4th, 2001, 09:05 PM
#1
Thread Starter
Addicted Member
How to get Application Path?
Good day, everybody...
Just one simple question....
How do I get the Path of the Executable program? I know in VB is 'App.Path'. But what function or statement that I can used in VC++?
Thanks.
-
Oct 4th, 2001, 11:24 PM
#2
PowerPoster
Use the API "GetModuleName". Here is an example:
PHP Code:
#include <windows.h>
#include <iostream.h>
int main()
{
int x;
char filename[MAX_PATH];
GetModuleFileName(GetModuleHandle(NULL), filename, MAX_PATH);
cout<<filename;
cin>>x;
return 0;
}
-
Oct 5th, 2001, 02:45 PM
#3
You could use the old-DOS style method, and represent it using a dot, e.g:
Code:
char *path = ".\\MyFile.txt"
-
Oct 5th, 2001, 02:50 PM
#4
PowerPoster
is that what you use to find the windows directory too?
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 5th, 2001, 02:54 PM
#5
Originally posted by sail3005
is that what you use to find the windows directory too?
you can use the GetWindowsDirectory function. If you include windows.h
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Oct 5th, 2001, 02:54 PM
#6
PowerPoster
oh, ok. i didn't know there was a specific function for it
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 6th, 2001, 06:43 AM
#7
Frenzied Member
oh, ok. i didn't know there was a specific function for it
There is a special function for almost every important windows directory.
-
Oct 6th, 2001, 10:33 AM
#8
Originally posted by sail3005
is that what you use to find the windows directory too?
The dot is just a place holder for the current directory.
-
Oct 7th, 2001, 11:11 PM
#9
Thread Starter
Addicted Member
Megatron,
Will the old DOS-style that you gave gives any problem if I have a few files with the same name on different directory?
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
|