G
Gnic
Hi,
I have a (Complied) C Library that needs to be called using c# code, some of
the function require char* parameter(in and out)
Here is the problem,
There is a function that expect an input char* parameter
for example
int AddString(const char* someStr)
And then there is another function to retrieve the value I pass in using the
above function
for example
int GetString(char* rntStr)
In C#
[DllImport(......)]
Int32 AddString(string someStr);
[DllImport(..)]
Int32 GetString(string rntString);
So when I input "aaaa" into someStr and get the return by calling GetString,
the rntString variable only return the first character ("a") and the length
of the string is 1.
Anyone know what's wrong with my code?
It the AssString declaration problem or the GetString declaration problem
(or both)?
thanks
Gasnic
I have a (Complied) C Library that needs to be called using c# code, some of
the function require char* parameter(in and out)
Here is the problem,
There is a function that expect an input char* parameter
for example
int AddString(const char* someStr)
And then there is another function to retrieve the value I pass in using the
above function
for example
int GetString(char* rntStr)
In C#
[DllImport(......)]
Int32 AddString(string someStr);
[DllImport(..)]
Int32 GetString(string rntString);
So when I input "aaaa" into someStr and get the return by calling GetString,
the rntString variable only return the first character ("a") and the length
of the string is 1.
Anyone know what's wrong with my code?
It the AssString declaration problem or the GetString declaration problem
(or both)?
thanks
Gasnic