Fream_Ni 2016-02-18 09:12 采纳率: 0%
浏览 1973

vc中使用ado,使用Unicode字符集下comdef.h文件中报错

vc中使用ado,使用Unicode字符集下comdef.h文件中的_com_error::ErrorMessage() const throw() 函数报错,求解决方法,具体位置如下:

inline const TCHAR * _com_error::ErrorMessage() const throw()

{

    if (m_pszMsg == NULL) 
    {
    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|
                      FORMAT_MESSAGE_FROM_SYSTEM|
                      FORMAT_MESSAGE_IGNORE_INSERTS,
                  NULL,
                  m_hresult,
                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                  (LPTSTR)&m_pszMsg,
                  0,
                  NULL);
    if (m_pszMsg != NULL)
            {
        int nLen = lstrlen(m_pszMsg);
        if (nLen > 1 && m_pszMsg[nLen - 1] == '\n') {
            m_pszMsg[nLen - 1] = 0;
            if (m_pszMsg[nLen - 2] == '\r') {
                    m_pszMsg[nLen - 2] = 0;
            }
        }
    } 
    else 
            {
        m_pszMsg = (LPTSTR)LocalAlloc(0, 32 * sizeof(TCHAR));
        if (m_pszMsg != NULL) {
            WORD wCode = WCode();
            if (wCode != 0) {
                _COM_PRINTF_S_1(m_pszMsg, 32, TEXT("IDispatch error #%d"), wCode);       报错位置
            } 
            else 
                            {
                _COM_PRINTF_S_1(m_pszMsg, 32, TEXT("Unknown error 0x%0lX"), m_hresult); 报错位置
            }
        }
    }
}
return m_pszMsg;

}

错误 59 error C2664: “int swprintf_s(wchar_t *,size_t,const wchar_t *,...)”: 不能将参数 3 从“const char [20]”转换为“const wchar_t *” C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\comdef.h 257

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-02-18 09:23
    关注
     TEXT("IDispatch error #%d")
    ->
    L"IDispatch error #%d"
    
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?