Why you do not want to modify native part that it would receive UNICODE
string?
If this is impossible, you can try to pass your string as byte array:
byte [] b = System.Text.Encoding.ASCII.GetBytes("Password");
Configure(b, b.Length);
....
[DllImport("Protocol.dll")]
static extern int Configure(byte [] password, int pwdSize);
Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
Arnau Font wrote:
> Hi,
>
> I'm trying to invoke a function in a DLL, using DllImport. One of the
> parameters is a ANSI string, but the CharSet enumeration has only the Auto
> and Unicode members. How can I send a string in ANSI to the DLL?
>
>
> [DllImport("Protocol.dll", CharSet = CharSet.Auto)]
> static extern int Configure(string password, uint pwdSize); //The password
> should be passed as ANSI
>
> Thanks!
>
>