Reputation:
I have the following dll cpp file
#include "stdafx.h"
#include <string.h>
#include <Windows.h>
#include <OleAuto.h>
using namespace std;
extern "C" __declspec(dllexport) BSTR func(BSTR a)
{
BSTR buffer;
buffer = SysAllocString(a);
return buffer;
}
At the vb end
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim string1 As String
string1 = func(TextBox1.Text)
TextBox2.Text = string1
End Sub
The above code compiles properly but the form closes before displaying the string in the textbox. But if I return the text as an integer, it works fine...
Upvotes: 0
Views: 938
Reputation: 175
BSTR != VB.NET String i think ,,, use LPCSTR
extern "C" __declspec(dllexport) LPCSTR func(LPCSTR a)
Upvotes: 1