String^, LCSTR and NULL

F

Franz.Jacob

Hi NG,

I wonder how to pass NULL pointer of type String^ to function call.

I have a native DLL:

extern "C" long __declspec(dllimport) __stdcall Test(LPCSTR a, LPCSTR
b = 0);

with optional/default parameter b.

Now I define:

#define LPCSTR [MarshalAs(UnmanagedType::LPStr)]String^

To use implicit managed to unmanaged copy of my String^ values.

But how could I use default value (b = 0) with String^ values?

I won't use function Test like this:

String ^a = "a";
String ^b;
Test(a, b);

to use it with b as NULL value.
Instead I would like to use it in this way:

String ^a = "a";
Test(a);

and b should be set (as it should) to NULL or what ever it is calles in
..NET

BTW, b is not the only default/optional value...


regards
Franz
 

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