wcsicmp 和 wsprintfW

中国蓝计划 2010-07-23 12:54:48
原版的代码编译没错,为什么加入到我的代码出错了?(代码我是直接导入的) 是缺少什么头文件造成的吗?
达人们,偶急需解决~~~



错误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) );
}
}






...全文
854 39 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
39 条回复
切换为时间正序
请发表友善的回复…
发表回复
lazy_2010 2010-07-23
  • 打赏
  • 举报
回复
_ATL_MIN_CRT 代表不使用 C 运行库,而是使用一个很小的 C 库,所以出现 _main 函数链接问题,可以去掉的,没有关系,在实现 COM 组件的时候这个问题很常见。
中国蓝计划 2010-07-23
  • 打赏
  • 举报
回复
我现在的工程是什么类型,我都很郁闷!
oyljerry 2010-07-23
  • 打赏
  • 举报
回复
[Quote=引用 36 楼 redsleaf 的回复:]

to lazy_2010 的方法确实可以解决问题
但是:
1,将 _ATL_MIN_CRT 删除
2,将 _wcsicmp 替换为 stricmp
3,将 wsprintf 替换为 wsprintfA

会对程序什么地方有影响?希望能详细讲下!多谢啦!
[/Quote]
2.3 使用ANSI API ,不使用unicode API,影响不大
1.最好还是建立正确的工程类型
中国蓝计划 2010-07-23
  • 打赏
  • 举报
回复
to lazy_2010 的方法确实可以解决问题
但是:
1,将 _ATL_MIN_CRT 删除
2,将 _wcsicmp 替换为 stricmp
3,将 wsprintf 替换为 wsprintfA

会对程序什么地方有影响?希望能详细讲下!多谢啦!
flyskytoday 2010-07-23
  • 打赏
  • 举报
回复
学习,学习

这个问题,也遇到过,困了好几天,解决方法吗??给你留言
lazy_2010 2010-07-23
  • 打赏
  • 举报
回复
也许需要把宏 _ATL_MIN_CRT 去掉,就可以解决 _main 的问题
oyljerry 2010-07-23
  • 打赏
  • 举报
回复
Creating library ReleaseUMinDependency/vbMHWB.lib and object ReleaseUMinDependency/vbMHWB.exp
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main

--- 你的工程类型不对,在你工程属性中,把你的工程改为console
中国蓝计划 2010-07-23
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20100719/12/8f99bbf2-a610-4624-a1fe-be854a6aa302.html

这些怎么用呢,老大
3jaja 2010-07-23
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20100719/12/8f99bbf2-a610-4624-a1fe-be854a6aa302.html
lazy_2010 2010-07-23
  • 打赏
  • 举报
回复
应该是修改 project 配置;实在不行,使用 StrCmpI wsprintf
中国蓝计划 2010-07-23
  • 打赏
  • 举报
回复
谁能加Q帮我啊 除了这个还有个问题 3100181(常年不在线 请发送请求 csdn)

如能加我QQ 解决了!一次性发5帖 400分,献上!分不多(但我已经露底了!)
中国蓝计划 2010-07-23
  • 打赏
  • 举报
回复
to weizehua
没什么修改还是老样子! sprintf 未定义!
中国蓝计划 2010-07-23
  • 打赏
  • 举报
回复
恩,不知道怎么了,我选中 win debug 后点确定,然后再打开还是ReleaseUMinDependency
是在没办法,才求你看看能换个函数实现不!
Happy0403 2010-07-23
  • 打赏
  • 举报
回复
不好意思,再次更正方法三:
方法三绝对不管用。。。因为我忘记它不是改字符串的默认属性了。

应该这样改源:
或者用方法一和二(差不多的)

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字符集的
Happy0403 2010-07-23
  • 打赏
  • 举报
回复
方法三错了。。。
应该是使用UNICODE字符集。。看没清楚,请原谅
lazy_2010 2010-07-23
  • 打赏
  • 举报
回复
从 ReleaseUMinDependency 来看,你选择的是 Unicode Release Minimum Dependency 的配置,你还是选择不带 Unicode 的那个版本更好;

stricmp 还可以使用 _memicmp 进行替换
中国蓝计划 2010-07-23
  • 打赏
  • 举报
回复
当我使用 toupper 和 stricmp 之类的函数都会出现如上的错误,希望能换个实现的方法!
Happy0403 2010-07-23
  • 打赏
  • 举报
回复
方法一:
在所有字符串前家个大些的'L'
如:
L"string"
方法二:
用_T将字符串括起来

_T("string")
方法三:
配置属性-》常规-》使用多字节字符集(VS2008)
中国蓝计划 2010-07-23
  • 打赏
  • 举报
回复
stricmp 还能用其他方法解决不!
中国蓝计划 2010-07-23
  • 打赏
  • 举报
回复
字符输错了,呵呵

修改后,还是有错误

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...
加载更多回复(19)

16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧