0
TCHAR* pszBackupPath;
m_Edt_ExportPath.GetWindowText(pszBackupPath, dwcchBackupPath);
StrTrim(pszBackupPath, L" ");
StrTrim(pszBackupPath, L"\\"); //this line has issue
iRet = _tcslen(pszBackupPath);
boRet = PathIsNetworkPath(pszBackupPath);
if (FALSE == boRet)
{
// MessageBox with string "Entered path is network path.
}
boRet = PathIsDirectory(pszBackupPath);
if (FALSE == boRet)
{
// MessageBox with string "Entered path is not a valid directory.
}
這是我的代碼在MFC中的一部分。 我正在通過UI的網絡路徑。但是由於StrTrim(pszBackupPath,L「\\」)「\\」會從開始和結束進行修剪。但我希望它僅從最後修剪。 我不知道任何直接的API。請建議。希望它被修剪我的TCHAR *從最後只有
你在哪裏初始化'pszBackupPath'?你的代碼聲明瞭一個指針,然後你將這個未初始化的指針傳遞給'GetWindowText'。這是行不通的,我很驚訝代碼沒有崩潰。一個'TCHAR *'不是一個字符串 - 它是一個單獨的指針,它需要先指向一個緩衝區,然後再對它進行任何操作。 – PaulMcKenzie