equivalent char* in C#

The C# way of doing this is by letting the marshaler handle the char* stuff while you work with a string:

[DllImport("pjsipDlld")]
static extern int dll_registerAccount(
    [MarshalAs(UnmanagedType.LPStr)]string username,
    [MarshalAs(UnmanagedType.LPStr)]string password);

Replace LPStr with LPWStr if you’re working with wide chars.

Leave a Comment