加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

vs2005非托管方式调用webservice

发布时间:2020-12-16 21:54:30 所属栏目:安全 来源:网络整理
导读:soapkit3.0,中的列子用vs2005非托管方式调用的例子,注意BSTR和char之间的转换例子代码 // console2.cpp : 定义控制台应用程序的入口点。// #include "stdafx.h" #include comutil.h #pragma comment(lib,"comsuppw.lib") #pragma comment(lib,"kernel32.lib

soapkit3.0,中的列子用vs2005非托管方式调用的例子,注意BSTR和char之间的转换例子代码

// console2.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <comutil.h>
#pragma comment(lib,"comsuppw.lib") 
#pragma comment(lib,"kernel32.lib") 

#include <Locale.h>
using namespace  MyMath;
int _tmain(int argc,_TCHAR* argv[])
{
    ::CoInitialize(NULL);
  //CMyMathT<>  a;
    CMyMath a;
  double b;
  a.AddNumbers(3,6,&b);
  CString str;
  BSTR  bstrA=::SysAllocString(L"tan谭");
  BSTR  bstrB=NULL;
  a.EchoString(bstrA,&bstrB);
 // printf("return message is:%s",()bstrB);
    setlocale(LC_ALL,"chs");
  wprintf_s(L"return message is %sn",bstrB);
  char *  lpszText=_com_util::ConvertBSTRToString(bstrB);
  printf(lpszText);
  delete lpszText;
  ::SysFreeString(bstrA);
  if(bstrB!=NULL){
      printf("release message.n");
       ::SysFreeString(bstrB);
       printf("谭ddd");
  }

  //a.EchoString(
  printf("%f",b);

    printf("t-?ttttFor Helpn");

         printf("中文测试n");

         //setlocale(LC_ALL,"zh_CN.UTF-8");

         setlocale(LC_ALL,"chs");

         wprintf(L"中文测试n");

         printf("w0:%lsn",L"中文测试");

         wprintf(L"w1:%sn",L"1中文测试 宽字符");

         wprintf(L"w2:%lsn",L"2中文测试 宽字符");

         wprintf(L"w3:%lsn",L"3tDirectory 中文测试 宽字符 end");

         wprintf(L"w4:%Sn",L"4 中文测试 宽字符 end");

         printf("w5:%Sn",L"中文测试n");
  getchar();
  ::CoUninitialize();

    return 0;
}

下边为常用的关于字符的处理方法
vc6一般为多字节编码,如果想要unicode,要改:工程>设置>c/c++>预处理程序定义>去掉_MBCS,加入
:_UNICODE,UNICODE;工程>设置>link>output>Entry point加入wWinMainCRTStartup

为了兼容ansi,unicode常用函数改为 strcpy,strlen,strcat-> _tcscpy,_tcslen,_tcscat或lstrcpy,lstrlen,lstrcat printf,sprintf->_tprintf,_tsprintf “xxxx”-> _T(“xxxx”)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读