marshal unsigned char pointer

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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...
 
Back
Top