B
Beorne
I have to call a c++ library funtion returning a string with the
following signature:
char *get_identifier();
Usually when I have to marshal a function with a char* output
parameter I do:
[DllImport("library.dll", CharSet = CharSet.Ansi,)]
static extern int get_identifier2([MarshalAs(UnmanagedType.LPStr)]
StringBuilder Ack_Msg, int msg_len);
But in this case the char* string is returned as output.
I've tried
[DllImport("library.dll", CharSet = CharSet.Ansi,)]
static extern [MarshalAs(UnmanagedType.LPStr)] StringBuilder
get_identifier();
but this does throw an error.
How I could do to state explicitly that the returning char string is
an ansi (LPStr) string?
And how could I find the size of the returned string?
Thanks.
following signature:
char *get_identifier();
Usually when I have to marshal a function with a char* output
parameter I do:
[DllImport("library.dll", CharSet = CharSet.Ansi,)]
static extern int get_identifier2([MarshalAs(UnmanagedType.LPStr)]
StringBuilder Ack_Msg, int msg_len);
But in this case the char* string is returned as output.
I've tried
[DllImport("library.dll", CharSet = CharSet.Ansi,)]
static extern [MarshalAs(UnmanagedType.LPStr)] StringBuilder
get_identifier();
but this does throw an error.
How I could do to state explicitly that the returning char string is
an ansi (LPStr) string?
And how could I find the size of the returned string?
Thanks.