C#/PInvoke knows about C style char* NULL terminated strings so you
shouldn't have to do anything special if the string is a null terminated IN
parameter, here's the default type conversion chart for .NET PInvoke:
http://msdn.microsoft.com/library/de...edatatypes.asp
If you need to pass a string buffer aka if the C++ declaration expects "char
sz[21]" then you can do that with a MarshalAs UnmanagedType.ByValTStr or a
StringBuilder depending on your needs. PInvoke string marshalling is
discussed at length here:
http://msdn.microsoft.com/library/de...edatatypes.asp
"GEES" wrote:
> Friends,
>
> I would like to access a function in a dll file.
>
> I have the call from a vb programme, it looks like
> Declare Function bapiVersionInfo Lib "bapi" (ByVal versionString As String,
> ByVal maxSize As long) As long
> I c# I would do it as followes:
>
> [DllImport("BAPI.DLL", EntryPoint = "bapiVersionInfo", CharSet =
> CharSet.Ansi)]
>
> public static extern int bapiVersionInfo([MarshalAs(UnmanagedType.LPStr)]
> string versionString, int maxSize);
>
> The problem is that the dll is a on bibary based C++ file. Fromout C# the
> long is transferred to a int. But hou to handle the string????
>
> Regards
>
> Gerrit Esmeijer
>
>
>
>
>
>
>
>