C, C++, To select a file and get path and file name using CFileDialog function, example source code

TCHAR szFilter[] = _T("All Files(*.*)|*.*||");
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, szFilter);

CString strPathName, m_filename;
if(IDOK == dlg.DoModal()) {
 m_filename=dlg.GetFileName();   //file name
 strPathName = dlg.GetPathName(); //full path info
}

..



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);



C, C++, The meaning of LPSTR, LPCSTR, LPTSTR, LPCTSTR, LPWSTR

LP is Long Pointer.
C is constant.
STR is String.

LPSTR = long pointer string = char*
LPCSTR = long pointer constant string = const char*



W means Wide char and unicode.

LPWSTR = long porinter wide string = w_char*
LPCWSTR = long porinter constant wide string = const w_char*


T is ..

LPCTSTR = long pointer constant t_string = const tchar*