55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LeatherApp.Utils
|
|
{
|
|
public class ScreenKeyboard
|
|
{
|
|
public static bool isShowNumBoard = false;
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)]
|
|
public static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)]
|
|
public static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
|
|
|
|
public static IntPtr ptr = new IntPtr();
|
|
|
|
public static void ShowScreenKeyboard()
|
|
{
|
|
try
|
|
{
|
|
//判断软键盘是否进程是否已经存在,如果不存在进行调用
|
|
Process[] pro = Process.GetProcessesByName("osk");
|
|
bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr);
|
|
|
|
//键盘如果已经打开则重新打开,防止最小化无法显示
|
|
if (pro != null && pro.Length > 0)
|
|
{
|
|
Process kbpr = pro[0];
|
|
kbpr.Kill();
|
|
if (isWow64FsRedirectionDisabled)
|
|
{
|
|
Process.Start(@"C:\WINDOWS\system32\osk.exe");
|
|
Wow64RevertWow64FsRedirection(ptr);
|
|
}
|
|
return;
|
|
}
|
|
if (isWow64FsRedirectionDisabled)
|
|
{
|
|
Process.Start(@"C:\WINDOWS\system32\osk.exe");
|
|
Wow64RevertWow64FsRedirection(ptr);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|