社区
Web Services
帖子详情
BSTR是什么类型,在VC++.NET调用WEBSERVICE的方法时,string与BSTR如何转化
webjimcn
2004-10-15 04:40:44
webservice 用C#写成,client端用VC++.net写,在VC++.NET调用WEBSERVICE的方法时,string与BSTR如何转化,本来是string method(string,string),引用后,却变成了BSTR.string与BSTR如何转化
...全文
267
7
打赏
收藏
BSTR是什么类型,在VC++.NET调用WEBSERVICE的方法时,string与BSTR如何转化
webservice 用C#写成,client端用VC++.net写,在VC++.NET调用WEBSERVICE的方法时,string与BSTR如何转化,本来是string method(string,string),引用后,却变成了BSTR.string与BSTR如何转化
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
真相重于对错
2005-09-08
打赏
举报
回复
vc++ 2005 ???
蒋晟
2005-09-08
打赏
举报
回复
// MarshalBSTR1.cpp
// compile with: /clr
#define WINVER 0x0502
#define _AFXDLL
#include <afxwin.h>
#include <iostream>
using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;
#pragma unmanaged
void NativeTakesAString(BSTR bstr)
{
printf_s("%S", bstr);
}
#pragma managed
int main()
{
String^ s = "test string";
IntPtr ip = Marshal::StringToBSTR(s);
BSTR bs = static_cast<BSTR>(ip.ToPointer());
pin_ptr<BSTR> b = &bs;
NativeTakesAString( bs );
Marshal::FreeBSTR(ip);
return 0;
}
// MarshalBSTR2.cpp
// compile with: /clr
#define WINVER 0x0502
#define _AFXDLL
#include <afxwin.h>
#include <iostream>
using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;
#pragma managed
void ManagedTakesAString(BSTR bstr)
{
String^ s = Marshal::PtrToStringBSTR(static_cast<IntPtr>(bstr));
Console::WriteLine("(managed) convered BSTR to String: '{0}'", s);
}
#pragma unmanaged
void UnManagedFunc()
{
BSTR bs = SysAllocString(L"test string");
printf_s("(unmanaged) passing BSTR to managed func...\n");
ManagedTakesAString(bs);
}
#pragma managed
int main()
{
UnManagedFunc();
return 0;
}
蒋晟
2005-09-08
打赏
举报
回复
// MarshalBSTR1.cpp
// compile with: /clr
#define WINVER 0x0502
#define _AFXDLL
#include <afxwin.h>
#include <iostream>
using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;
#pragma unmanaged
void NativeTakesAString(BSTR bstr)
{
printf_s("%S", bstr);
}
#pragma managed
int main()
{
String^ s = "test string";
IntPtr ip = Marshal::StringToBSTR(s);
BSTR bs = static_cast<BSTR>(ip.ToPointer());
pin_ptr<BSTR> b = &bs;
NativeTakesAString( bs );
Marshal::FreeBSTR(ip);
return 0;
}
// MarshalBSTR2.cpp
// compile with: /clr
#define WINVER 0x0502
#define _AFXDLL
#include <afxwin.h>
#include <iostream>
using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;
#pragma managed
void ManagedTakesAString(BSTR bstr)
{
String^ s = Marshal::PtrToStringBSTR(static_cast<IntPtr>(bstr));
Console::WriteLine("(managed) convered BSTR to String: '{0}'", s);
}
#pragma unmanaged
void UnManagedFunc()
{
BSTR bs = SysAllocString(L"test string");
printf_s("(unmanaged) passing BSTR to managed func...\n");
ManagedTakesAString(bs);
}
#pragma managed
int main()
{
UnManagedFunc();
return 0;
}
Little_Ghost
2005-09-06
打赏
举报
回复
CSring str = "This is a string";
BSTR bstr = str.AllocSys...();//(具体记不清,应该是点出来的第一个函数)
CString str2 = (CString)bstr;//能够直接强制转换
Tomgus
2004-10-15
打赏
举报
回复
http://dev.csdn.net/article/35/35969.shtm
wangxt
2004-10-15
打赏
举报
回复
帮你顶
真相重于对错
2004-10-15
打赏
举报
回复
using CONVERTION;
BSTR bstr;
char* tstr = b2t(bstr);
bstr = T2B( tstr );
vc6.0
调用
webservice
的
方法
### vc6.0
调用
WebService
的
方法
详解 在深入探讨如何使用Visual
C++
6.0(简称VC6.0)来
调用
WebService
之前,我们首先需要了解几个基本概念:SOAP、
WebService
以及它们与VC6.0的关系。 #### SOAP(Simple Object ...
C++
通过msxml
调用
webservice
示例分享
在
C++
编程中,通过MSXML库
调用
Web服务(
WebService
)是一种常见的技术,特别是当需要与基于SOAP(简单对象访问协议)的Web服务进行交互
时
。MSXML,即Microsoft XML Core Services,提供了用于处理XML文档和执行...
VC
调用
WEBSERVICE
在V
C++
编程中,
调用
Web Service是一种常见的需求,它允许本地应用程序与远程服务器上的功能进行交互。在本示例中,我们看到一个V
C++
应用如何通过COM接口使用SOAP(简单对象访问协议)来
调用
Web Service。以下是该...
V
C++
6.0
调用
Web Services(可以是c#,java,v
c++
.net
等提供的服务都可以)!
本文主要讲述V
C++
6.0
调用
Web Services的
方法
,其中web services可以是c#,java,v
c++
.net
等提供的服务都可以
调用
!主要的大致过程如下: 需要装Soap Toolkit3.0,电脑上一般自带Soap Toolkit1.0,以下...
Web Services
12,165
社区成员
16,325
社区内容
发帖
与我相关
我的任务
Web Services
.NET技术 Web Services
复制链接
扫一扫
分享
社区描述
.NET技术 Web Services
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章