Reputation:
I got the next c function:
long _stdcall _MakePipeString(char *szOut, long nOutChars, const char *szXmlFile, long nOptions);
And I try to use pInvioke like this:
[DllImport("diXo10.dll")]
public static extern long _MakePipeString(out StringBuilder szOut, out long nOutChars, string szXmlFile, long nOptions);
But i get null in the ouput variable szOut.
Am I doing wrong?
Please help.
Upvotes: 0
Views: 238
Reputation: 4798
In additions to what others have said, change the longs to ints on the C# side.
Upvotes: 1
Reputation: 60190
Have you tried:
[DllImport("diXo10.dll")]
public static extern long _MakePipeString([MarshalAs(UnmanagedType.LPStr)] out String szOut, out long nOutChars, [MarshalAs(UnmanagedType.LPStr)] string szXmlFile, long nOptions);
Note that you may also have to specify whether you expect ANSI or Unicode(UTF16) characters, for instance by using LPTStr/LPWStr instead of LPStr or on the DllImport attribute.
Upvotes: 0