Hi everyone,
I wrote a dll which is export char* like;
extern "C" __declspec(dllexport) char* Test(void)
{
char* cts = "hi";
return cts;
}
and import the dll on vb.net like;
Declare Ansi Function Test Lib "[Path]" Alias "Test" () As String
and call like;
Private Sub Form_Load (...)
Dim a As String = Nothing
a = Test
MsgBox(a)
End Sub
There isn't any problem. But I want to use CString and convert CString to char pointer and then export the pointer, like;
extern "C" __declspec(dllexport) char* Test(void)
{
CString a(L"hi");
char* cts = (char*)(LPCTSTR)a;
return cts;
}
After the same VB.Net import and call functions, when the form is load (and Form_Load function called) then a error thrown as "AccessViolationError" (if I'm not wrong).
My question is how can I export char pointer (converted from CString variable) and use on VB.Net?
PS: Sorry for my English. By the way I'm using Visual Studio (VC++8)