.net调用系统软键盘(兼容win7及win10)

杰克.陈 2018-10-22

windows path PTR kernel string static dll

原文:.net调用系统软键盘(兼容win7及win10)

没有什么技术说明,也是查询出来的,在此做记录

public class StartKeyBoard
    {
        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 void StartKeyBoardFun()
        {
            string path = "C:/Program Files/Common Files/microsoft shared/ink/TabTip.exe";
            if (File.Exists(path))
            {
                Process p = Process.Start(path);
            }
            else
            {
                //判断软键盘是否进程是否已经存在,如果不存在进行调用
                Process[] pro = Process.GetProcessesByName("osk");
                //说明已经存在,不再进行调用
                if (pro != null && pro.Length > 0)
                    return;
                IntPtr ptr = new IntPtr();
                bool isWow64FsRedirectionDisabled = Wow64DisableWow64FsRedirection(ref ptr);
                if (isWow64FsRedirectionDisabled)
                {
                    Process.Start(@"C:\WINDOWS\system32\osk.exe");
                    bool isWow64FsRedirectionReverted = Wow64RevertWow64FsRedirection(ptr);
                }
            }
        }

    }

登录 后评论
下一篇
corcosa
15233人浏览
2019-10-08
相关推荐
关于windows中的快捷键
708人浏览
2017-11-14 11:50:00
windows快捷键使用
660人浏览
2017-11-12 17:23:00
Win7套路深,Win10要认真
704人浏览
2017-07-03 10:31:00
Windows XP 与Win7 VHD双启动
780人浏览
2017-11-26 16:09:00
TSF自定义候选词列表界面
438人浏览
2018-06-15 11:41:00
0
0
0
393