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.
Printable View
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.
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;
}
You could use the old-DOS style method, and represent it using a dot, e.g:
Code:char *path = ".\\MyFile.txt"
is that what you use to find the windows directory too?
you can use the GetWindowsDirectory function. If you include windows.hQuote:
Originally posted by sail3005
is that what you use to find the windows directory too?
:)
oh, ok. i didn't know there was a specific function for it
There is a special function for almost every important windows directory.Quote:
oh, ok. i didn't know there was a specific function for it
The dot is just a place holder for the current directory.Quote:
Originally posted by sail3005
is that what you use to find the windows directory too?
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?