革博士程序V1仓库
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

55 rindas
1.8 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace LeatherApp.Utils
  9. {
  10. public class ScreenKeyboard
  11. {
  12. public static bool isShowNumBoard = false;
  13. [DllImport("kernel32.dll", SetLastError = true)]
  14. public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
  15. [DllImport("kernel32.dll", SetLastError = true)]
  16. public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
  17. public static IntPtr ptr = new IntPtr();
  18. public static void ShowScreenKeyboard()
  19. {
  20. try
  21. {
  22. //判断软键盘是否进程是否已经存在,如果不存在进行调用
  23. Process[] pro = Process.GetProcessesByName("osk");
  24. bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr);
  25. //键盘如果已经打开则重新打开,防止最小化无法显示
  26. if (pro != null && pro.Length > 0)
  27. {
  28. Process kbpr = pro[0];
  29. kbpr.Kill();
  30. if (isWow64FsRedirectionDisabled)
  31. {
  32. Process.Start(@"C:\WINDOWS\system32\osk.exe");
  33. Wow64RevertWow64FsRedirection(ptr);
  34. }
  35. return;
  36. }
  37. if (isWow64FsRedirectionDisabled)
  38. {
  39. Process.Start(@"C:\WINDOWS\system32\osk.exe");
  40. Wow64RevertWow64FsRedirection(ptr);
  41. }
  42. }
  43. catch (Exception ex)
  44. {
  45. }
  46. }
  47. }
  48. }