CString类型转换为const char*类型

CString FilePathName;
int m = FilePathName.GetLength();
	for (int index = 0; index < m; index++) {
		if (FilePathName.GetAt(index) == '\\') {
			FilePathName.Insert(index, '\\');
			index++;
		}
	}
	LPCTSTR p = FilePathName.GetBuffer();
	DWORD dwMinSize;
	dwMinSize = WideCharToMultiByte(CP_ACP, NULL, p, -1, NULL, 0, NULL, FALSE);
	char * strFile = new char[dwMinSize];
	WideCharToMultiByte(CP_OEMCP, NULL, p, -1, strFile, dwMinSize, NULL, FALSE);

你可能感兴趣的:(解决方案,cstring)