[DllImport("user32.dll", CallingConvention = CallingConvention.WinApi)]
public static extern IntPtr FindWindow(
[MarshalAsAttribute(UnmanagedType.LPWStr)] string lpWindowClass,
[MarshalAsAttribute(UnmanagedType.LPWStr)] string lpWindowName
);
在相应的参数前加上 [MarshalAsAttribute(UnmanagedType.LPWStr)] ,这样就不会导致乱码了