Tips to get current and Program Files directory in Visual C
This samples use CString class for Visual Studio 2010. It seems to me that Microsoft begin to make some changes in mfc core classes.
Visual C code to get current directory
TCHAR pf[MAX_PATH];
CString str;
::GetModuleFileName(NULL, pf, MAX_PATH);
str = pf;
str = str.Mid(0,str.ReverseFind('\\')+1);
//str now is the Current directory
Visual C code to get Program Files directory
TCHAR pf[MAX_PATH];
SHGetSpecialFolderPath(
0,
pf,
CSIDL_PROGRAM_FILES,
FALSE );
//pf now is Program Files directory
|