3/13/2014

C,C++, Get current directory( path ), GetCurrentDirectory function

Get path
#Case 1
char reDir[500];
::GetCurrentDirectory(500,reDir);
::AfxMessageBox(reDir);

#Case 2
TCHAR buff[MAX_PATH];
memset(buff, 0, MAX_PATH);
::GetCurrentDirectory(MAX_PATH, buff);
CString strFolder = buff;





Get path & module name 
TCHAR buff[MAX_PATH]; 
 memset(buff, 0, MAX_PATH); 
 ::GetModuleFileName(NULL,buff,sizeof(buff)); 
 CString strFolder = buff; 
 strFolder = strFolder.Left(strFolder.ReverseFind(_T('\\'))+1);



No comments:

Post a Comment