Calling D DLL from C# and passing/retrieving string variables

Regan Heath regan at netmail.co.nz
Wed Oct 12 09:33:55 PDT 2011


On Wed, 12 Oct 2011 17:10:09 +0100, Trass3r <un at known.com> wrote:

>>         [DllImport("mydll.dll",
>>             CallingConvention = CallingConvention.Cdecl,
>>             SetLastError = false, CharSet = CharSet.Auto)]
>>             private static extern bool concatenate(
>>                 string str1, // in
>>                 string str2, // in
>>                 StringBuilder strResult); // out
>
> Question is if that StringBuilder really is equal to a char* in this  
> case.

I believe it can/does work with C DLLs, for example:
http://www.pinvoke.net/default.aspx/kernel32/FormatMessage.html

The first C# FormatMessage signature shown there uses a StringBuilder on  
the C# side.

R

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d-learn mailing list