marshal unsigned char pointer

G

Guest

Hello,
I am trying to call c++ dll function calls from C#. The c++ dll function
takes in pointer to unsigned char array. Can anybody help me in what
marshalling parameter value that i have to declare in C# side.

For eg:
in c++ X.dll the function is:
extern "C" __declspec(dllexport) void Getcharpointer(unsigned char* v)
{
//Just for test purpose, i alter and check on the C# side whether it
persists. This is another thing which i want to do but i cant.
v[0] = 'p';
}

on the c# side declaration:
--------------------------
[DllImport("X.dll",CharSet=CharSet.Auto)]
static extern Getcharpointer([MarshalAs( UnmanagedType.LPStr )]
System.String IncharPtr)
-----

IF i try this syntax, the change doesnt persist in the value of the first
index of unsigned char pointer array.
Can anybody help me here?.Is this is the right way?.

Thanks.,
Chellam.
 
T

Tom Shelton

Hello,
I am trying to call c++ dll function calls from C#. The c++ dll function
takes in pointer to unsigned char array. Can anybody help me in what
marshalling parameter value that i have to declare in C# side.

For eg:
in c++ X.dll the function is:
extern "C" __declspec(dllexport) void Getcharpointer(unsigned char* v)
{
//Just for test purpose, i alter and check on the C# side whether it
persists. This is another thing which i want to do but i cant.
v[0] = 'p';
}

on the c# side declaration:
--------------------------
[DllImport("X.dll",CharSet=CharSet.Auto)]
static extern Getcharpointer([MarshalAs( UnmanagedType.LPStr )]
System.String IncharPtr)
-----

IF i try this syntax, the change doesnt persist in the value of the first
index of unsigned char pointer array.
Can anybody help me here?.Is this is the right way?.

Thanks.,
Chellam.

using System.Text.StringBuilder instead of string...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top