CString GetFileNameByFilePath()
{
char pFileName[MAX_PATH] = {0};
//得到程序自身的全路径
DWORD dwRet = GetModuleFileNameW(NULL, (LPWCH)pFileName, MAX_PATH);
CString filepath ;
filepath.Format(_T("%s"),pFileName);
CString Result;
int nPos = filepath.ReverseFind(_T('\\'));
if ( nPos != -1 )
{
CString strTemp;
strTemp = filepath.Right( filepath.GetLength() - nPos - 1 );
Result = strTemp.Left( strTemp.ReverseFind(_T('.')) );
}
return Result; //返回文件名
}
#include
中使用
DWORD WINAPI GetModuleFileName(
_In_opt_ HMODULE hModule,
_Out_ LPTSTR lpFilename,
_In_ DWORD nSize
);
#include
中使用
void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext );
带路径的截取下不就可以了 这么讲究