StartKeyBoard.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Diagnostics;
  3. using System.IO;
  4. using System.Runtime.InteropServices;
  5. namespace Team.Utility
  6. {
  7. public class StartKeyBoard
  8. {
  9. public static bool isShowNumBoard = false;
  10. [DllImport("kernel32.dll", SetLastError = true)]
  11. public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
  12. [DllImport("kernel32.dll", SetLastError = true)]
  13. public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
  14. public static void StartKeyBoardFun()
  15. {
  16. string path = "C:/Program Files/Common Files/microsoft shared/ink/TabTip.exe";
  17. if (File.Exists(path))
  18. {
  19. _ = Process.Start(path);
  20. }
  21. else
  22. {
  23. //判断软键盘是否进程是否已经存在,如果不存在进行调用
  24. Process[] pro = Process.GetProcessesByName("osk");
  25. //说明已经存在,不再进行调用
  26. if (pro != null && pro.Length > 0)
  27. return;
  28. IntPtr ptr = new();
  29. bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr);
  30. if (isWow64FsRedirectionDisabled)
  31. {
  32. Process.Start(@"C:\WINDOWS\system32\osk.exe");
  33. bool isWow64FsRedirectionReverted = Wow64RevertWow64FsRedirection(ptr);
  34. }
  35. }
  36. }
  37. }
  38. }