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

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
 

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