Hi i have a C++ DLL.
What i am doing is that i am passing memory address to my C++ dll where it write message on that address and i want to read the message from that memory address.

Here is my C++ function.

int _stdcall Test(int res, wchar_t *text)

Now in my C#.Net test app .. if i use unsafe char* .. i am getting proper output.

//Declaration
static extern unsafe int Test(char* msg); 
//Implementation
char* SerrMsg = stackalloc char[255];
Test(sMsg);
string emsg = new string(sMsg);

Now implementing in vb.net i am getting jst 1st character by using stringbuilder.

//Dec
Private Shared Function Test(ByVal msg As StringBuilder) As Integer
//Imp
Dim sMsg As New StringBuilder(400)
Test(sMsg)
eMsg= sMsg.ToString()

What is the replacement for char* in VB.Net ?
Help would be appreciated.

Thanks

Hi,

Here's an example:

Dim associatedChar As Char
' Returns "A".
associatedChar = Chr(65)
' Returns "a".
associatedChar = Chr(97)
' Returns ">".
associatedChar = Chr(62)
' Returns "%".
associatedChar = Chr(37)

Hi,

Here's an example:

Dim associatedChar As Char
' Returns "A".
associatedChar = Chr(65)
' Returns "a".
associatedChar = Chr(97)
' Returns ">".
associatedChar = Chr(62)
' Returns "%".
associatedChar = Chr(37)

I am writing on that memory address in C++ and reading that memory address null terminated string in C#.
It seems it is assigning null character after every character.
So i am just getting the first character back.

Ok solved the problem
Needed to set characterset as unicode

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.