>Something like this:
>[DllImport("cfile.dll")]
[quoted text clipped - 4 lines]
>String tmp;
>tmp = Marshal.PtrToStringAnsi(TEST());
That's find as long as the C code returns a static string that doesn't
have to be freed.
>If this is correct then I guess I would have to do it every time I called
>the C DLL function from within C#? Anyway of getting around that? The
>reason I ask is because my customers will be writing C# code that uses the
>helper functions in the C DLL (think of C# as being like a scripting
>language). I would like to make it easy as possible for them to use.
I wouldn't recomment exposing DllImported functions directly anyway.
Wrap it up in a more .NET friendly interface that hides the
implementation details of calling the C API.
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Chuck C - 07 Nov 2006 13:04 GMT
Mattias,
Thanks for the input. What I ended up doing is what you suggested (what a
coinkydink!)
I have a base class that has DllImports marked as Private, and then wrapper
functions that are Public that do any extra conversion (such as the char *
return value). Worked out great!
Thanks for the help!
>>Something like this:
>>[DllImport("cfile.dll")]
[quoted text clipped - 20 lines]
>
> Mattias