我制作了一个 c++ builder ActiveX Library。当我制作连接到套接字并检查连接并从套接字读取并在套接字上写入的第一个 OCX 时。所有函数都在工作,但函数(从套接字读取并将字符串发送到 ActiveX 容器)返回类型为 BSTR(字符串)不起作用。运行项目后这段代码运行程序突然关闭。如何使用此功能将从套接字读取的数据发送到 ActiveX 容器?
//============ c++ builder xe8================
//I change the code to just return simple output"123"
//but it can not retun and c# program closed
BSTR STDMETHODCALLTYPE TSock4Impl::Read()
{
WCHAR ch[10];
ch[0]='1';
ch[1]='2';
ch[2]='3';
return ch;
}
//=============c# code ================
private void Form1_Load(object sender, EventArgs e)
{
//label1.Text = axVinaSock41.Read();
int a = axSock41.ConStatus();
label1.Text = Convert.ToString(a);
label1.Text = axVinaSock41.Read();// in this line the program was closed.
}