Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.

调用IIS管理组件时编写了下面一段代码,调用函数时提示错误:Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.  This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.

 1 std::wcout.imbue(std::locale("chs"));
 2 ::CoInitialize(NULL);
 3 
 4 CLSID clsid;
 5 HRESULT hr = ::CLSIDFromProgID(PROGID_WRITABLEADMINMANAGER, &clsid);
 6 
 7 CComPtr pAdminMgr;
 8 hr = ::CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER, IID_IDispatch, reinterpret_cast(&pAdminMgr));
 9 
10 CComVariant vtServerPath(XLOG_CFGSECTION_SERVER_XPATH);
11 CComVariant vtAppHost(CFG_PATH_APPHOST);
12 CComVariant vtServerConfigSection;
13 
14 hr = pAdminMgr.PutPropertyByName(_T("CommitPath"), &vtAppHost);

国外论坛不少人也提过这个问题将Calling Convention由原来的__cdecl (/Gd)修改为__stdcall (/Gz),其实是因为IUnknown被转换为IDispatch的问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值