原版的代码编译没错,为什么加入到我的代码出错了?(代码我是直接导入的)  是缺少什么头文件造成的吗?
达人们,偶急需解决~~~错误1  error C2664: '_wcsicmp' : cannot convert parameter 1 from 'char *' to 'const unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast错误2   error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [8]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast错误3   error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [8]' to 'unsigned short *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
HRESULT
CBehavior::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames,
                         LCID lcid, DISPID* rgdispid)
{
   HRESULT hr = DISP_E_UNKNOWNNAME;   USES_CONVERSION;   if (!rgszNames || !rgdispid )
      return E_POINTER;   for (int i = 0; m_szMethodNames[i] != NULL; i++)
   {
      if ( 0 == _tcsicmp( m_szMethodNames[i], OLE2A(*rgszNames) ) )//先把两字符串转化为小写后再比较。
      {
         *rgdispid = m_dispidMethodIDs[i];
         hr = S_OK;
      }
   }   return hr;
}void
CBehavior::ShowBehavior()
{
   CComPtr<IHTMLStyle> spStyle;
   HRESULT     hr;   hr = m_spElem->get_style( &spStyle );
   if ( SUCCEEDED(hr) )
   {
      DWORD color;
      char  buf[8];
      color = GetSysColor( m_lTextColorIndex );
      wsprintf( buf, "#%02x%02x%02x", GetRValue(color), GetGValue(color), GetBValue(color) );
      spStyle->put_color( CComVariant(buf) );     color = GetSysColor( m_lBackColorIndex );
      wsprintf( buf, "#%02x%02x%02x", GetRValue(color), GetGValue(color), GetBValue(color) );
      spStyle->put_backgroundColor( CComVariant(buf) );
   }
}

解决方案 »

  1.   

    你传入的参数类型是 char* 类型的,函数要求是 unicode 类型的;估计因为你使用的是高版本的 visual studio,项目缺省配置是 unicode 类型的,将项目配置修改成 MBCS 的应该就可以了
      

  2.   

    LZ需要了解一下UNICODE的知识~~~~
    http://kb.cnblogs.com/a/1721715/
      

  3.   

    在项目-》属性-> c/c++ ->语言-》将w_char设置为内置类型 选否
      

  4.   

    并将c/c++ 预处理器-》预处理器宏定义 _UNICODE UNICODE删除
      

  5.   

    " /D "_UNICODE"  程序中原来就设置了
      

  6.   

    宽字符和多字符的问题MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cchMultiByte, LPWSTR lpWideCharStr, int cchWideChar); 
      

  7.   

    在项目-》属性-> c/c++ ->语言-》将w_char设置为内置类型 选否
    并将c/c++ 预处理器-》预处理器宏定义 _UNICODE UNICODE删除
    这样做出现了,很多错误,希望不要这样!
      

  8.   

    晕,看错了,在项目-》属性-> c/c++ ->分类(c++ Language)-》将w_char设置为内置类型 选否分类(c++ Language)里
    1,指针成员的表示方法(就有两项)
    2,允许异常处理
    3,允许时间类型信息……
    4…… 看名字都不通没有看到  w_char 啊!
      

  9.   

    貌似 LZ 在编译 COM 组件,编译器使用的是 VC6,如果是这样,请选择配置 Win32 Debug,而不是 Win32 Unicode Debug
      

  10.   

    Build / Set Active Project Configuration 然后选择 win32 Debug
      

  11.   

    其它通过了
    error C2065: 'tcsicmp' : undeclared identifier这样做有什么坏处!希望达人讲明~~多谢!
      

  12.   

    字符输错了,呵呵修改后,还是有错误Compiling...
    Behavior.cpp
    Linking...
       Creating library ReleaseUMinDependency/vbMHWB.lib and object ReleaseUMinDependency/vbMHWB.exp
    LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    ReleaseUMinDependency/vbMHWB.dll : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.
    Creating browse info file...
      

  13.   

    stricmp 还能用其他方法解决不!
      

  14.   

    方法一:
    在所有字符串前家个大些的'L'
    如:
    L"string"
    方法二:
    用_T将字符串括起来

    _T("string")
    方法三:
    配置属性-》常规-》使用多字节字符集(VS2008)
      

  15.   

    从 ReleaseUMinDependency 来看,你选择的是 Unicode Release Minimum Dependency 的配置,你还是选择不带 Unicode 的那个版本更好;stricmp 还可以使用 _memicmp 进行替换
      

  16.   

    方法三错了
    应该是使用UNICODE字符集。。看没清楚,请原谅
      

  17.   

    当我使用 toupper 和 stricmp 之类的函数都会出现如上的错误,希望能换个实现的方法!
      

  18.   

    不好意思,再次更正方法三:
    方法三绝对不管用因为我忘记它不是改字符串的默认属性了。应该这样改源:
    或者用方法一和二(差不多的)      sprintf( buf, "#%02x%02x%02x", GetRValue(color), GetGValue(color), GetBValue(color) );
          spStyle->put_color( CComVariant(buf) );     color = GetSysColor( m_lBackColorIndex );
          sprintf( buf, "#%02x%02x%02x", GetRValue(color), GetGValue(color), GetBValue(color) );就是少了个w而已。。
    w是用来处理UNICODE字符集的
      

  19.   

    恩,不知道怎么了,我选中 win debug 后点确定,然后再打开还是ReleaseUMinDependency
    是在没办法,才求你看看能换个函数实现不!
      

  20.   

    to weizehua
    没什么修改还是老样子!  sprintf 未定义!
      

  21.   

    谁能加Q帮我啊 除了这个还有个问题  3100181(常年不在线  请发送请求 csdn)如能加我QQ 解决了!一次性发5帖 400分,献上!分不多(但我已经露底了!)
      

  22.   

    应该是修改 project 配置;实在不行,使用 StrCmpI wsprintf
      

  23.   

    http://topic.csdn.net/u/20100719/12/8f99bbf2-a610-4624-a1fe-be854a6aa302.html
      

  24.   

    http://topic.csdn.net/u/20100719/12/8f99bbf2-a610-4624-a1fe-be854a6aa302.html这些怎么用呢,老大
      

  25.   

      Creating library ReleaseUMinDependency/vbMHWB.lib and object ReleaseUMinDependency/vbMHWB.exp
    LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main--- 你的工程类型不对,在你工程属性中,把你的工程改为console
      

  26.   

    也许需要把宏 _ATL_MIN_CRT 去掉,就可以解决 _main 的问题
      

  27.   

    to  lazy_2010 的方法确实可以解决问题
    但是:
    1,将  _ATL_MIN_CRT  删除
    2,将 _wcsicmp 替换为 stricmp 
    3,将 wsprintf 替换为 wsprintfA会对程序什么地方有影响?希望能详细讲下!多谢啦!
      

  28.   

    2.3 使用ANSI API ,不使用unicode API,影响不大
    1.最好还是建立正确的工程类型
      

  29.   

    _ATL_MIN_CRT 代表不使用 C 运行库,而是使用一个很小的 C 库,所以出现 _main 函数链接问题,可以去掉的,没有关系,在实现 COM 组件的时候这个问题很常见。