版权声明:原创作品请注明出处: Ma_Hong_Kai CSDN https://blog.csdn.net/Ma_Hong_Kai/article/details/84957003
文件 ——> 新建项目 ——> win32控制台应用程序 ——> 右键属性 ——> 配置属性 ——> 配置类型 ——> MFC的使用(在静态库中使用MFC)
头文件
#pragma once
#include <iostream>
#include <afx.h>
wchar_t *fileType(CString strFilePath );
#include "a2b.h"
// 获取位置a到位置b的字符串
wchar_t *fileType(CString strFilePath )
{
CString str(strFilePath);
int posa = str.ReverseFind(_T('.'));
std::cout << posa << std::endl;
str = str.Right(str.GetLength()-posa -1 );
std::wcout << str.GetBuffer() << std::endl;
if ( wcscmp(str.GetBuffer(),_T("rar") ) == 0)
{
std::cout << "is rar" << std::endl;
}
return str.GetBuffer();
}
#include "a2b.h"
int main()
{
CString str = "1.hh.h.rar.....rar";
CString type(fileType(str));
std::wcout << type.GetBuffer() << std::endl;
system("pause");
return 0;
}