解决unity发布exe在win7电脑上部显示输入法的问题。
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string className, string windowName);
[DllImport("user32.dll")]
internal static extern IntPtr SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private void GetFocusWin()
{
//System.Diagnostics.Process currentProcess = System.Diagnostics.Process.GetCurrentProcess();
//IntPtr hWnd = currentProcess.MainWindowHandle;
IntPtr hWnd = FindWindow(null, "TestGPU1");
if (hWnd != IntPtr.Zero)
{
SetForegroundWindow(hWnd);
ShowWindow(hWnd, 10); // SW_SHOWDEFAULT = 10, SW_MAXIMIZE = 3, SW_SHOW = 5
}
else
{
Debug.LogWarning("GetFocusWin() failed, hWnd is 0!");
}
}