1. 程式人生 > >c# dllimport 呼叫函式,引數亂碼

c# dllimport 呼叫函式,引數亂碼

[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool WritePrivateProfileString(string lpAppName, string lpKeyName, string lpString, string lpFileName);

 

原因是沒有設定CharSet = CharSet.Auto這個屬性