How to call a C++ Method form C# which has char* as parameter

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I have a c++ dll, whose signature is given below.
bapiVersionInfo(char *versionString, UINT size);

Where in c++, the caller has to allocate the memory and has to specifiy the
size of the allocated memory.
For Eg.

#Include <BABP.h>

const int size = 10;
void GetVersion()
{
char *versionString = new char[size]
bapiVersionInfo(versionString, size);

// Get the verion form the dll.
printf("The current version is %s ", versionString );

// Clear the allocated memory
delete[] versionString;
}

The above mentioned is the typical example for getting the version number of
current dll.

Here in the c#,
[DllImport("bapi.dll")]
public static extern BPRETINT bapiVersionInfo(XYZ ptrVersionString, UInt32
size);

What should be the XXY type to wrap the method and how I should call this
method form the C# source code in order to get the version number of the dll.

Thanks

With regards
Venkat
 
Back
Top