Error:“const char*”类型的实参与“wchar_t”类型的形参不兼容

MainAppRPolarView.cpp(1571): error C2664: “ATL::CStringT<BaseType,StringTraits>::ReverseFind”: 不能将参数 1 从“const char [2]”转换为“wchar_t”
1> with
1> [
1> BaseType=wchar_t,
1> StringTraits=StrTraitMFC_DLL<wchar_t>
1> ]
1> 没有使该转换得以执行的上下文

CString GetModulePath(CString name)
{    
    char lpFilename[2000];
    DWORD nSize = 2000;
    // 得到应用程序的文件名
    GetModuleFileName(NULL,L"lpFilename",nSize);
    CString strFileName = (CString)lpFilename;
    int pos = strFileName.ReverseFind("\");
    if(pos<0)
        return L"";
    return strFileName.Left(pos+1)+name;
};

 改成:

即可

CString GetModulePath(CString name)
{    
    char lpFilename[2000];
    DWORD nSize = 2000;
    // 得到应用程序的文件名
    GetModuleFileName(NULL,L"lpFilename",nSize);
    CString strFileName = (CString)lpFilename;
    int pos = strFileName.ReverseFind('\');
    if(pos<0)
        return L"";
    return strFileName.Left(pos+1)+name;
};
原文地址:https://www.cnblogs.com/wxl845235800/p/8870354.html