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