• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C#挂起进程PostMessage使用

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
        #region  暂停进程

        //检测进程是否存在


        public List<IntPtr> get_pressId(string pressName = "explorer")
        {
            List<IntPtr> list = new List<IntPtr>();

            //获得进程ID
            Process[] processes = Process.GetProcesses();
            foreach (Process process in processes)
            {
                if (process.ProcessName == pressName)
                {
                    list.Add(process.Handle);
                }
            }

            return list;
            ////挂起进程
            //NtSuspendProcess(ip);
            ////恢复
            //NtResumeProcess(ip);
        }

        [DllImport("ntdll.dll")]
        private static extern uint NtSuspendProcess([In] IntPtr processHandle);

        [DllImport("ntdll.dll")]
        private static extern uint NtResumeProcess([In] IntPtr processHandle);


        #endregion




  /// <summary>
        /// js c#回调类
        /// </summary>
        public class ScriptCallbackManager
        {
            //转自:https://www.cnblogs.com/sntetwt/p/9269691.html

            private const Int32 WM_SYSCOMMAND = 274;
            private const UInt32 SC_CLOSE = 61536;
            [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
            private static extern bool PostMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
            [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
            private static extern bool PostMessage(IntPtr hWnd, int Msg, uint wParam, uint lParam);
            [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
            private static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
            [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
            private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
            [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
            private static extern int RegisterWindowMessage(string lpString);



            public void FindComputerInfo(IJavascriptCallback javascriptCallback)
            {
                Task.Factory.StartNew(async () =>
                {
                    using (javascriptCallback)
                    {
                        await javascriptCallback.ExecuteAsync("00");
                    }
                });
            }

            //显示屏幕键盘
            public int ShowInputPanel()
            {
                try
                {
                    Process.Start("key.exe", "osk");

                    return 1;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);

                    return 255;
                }
            }
            ////隐藏屏幕键盘
            public void HideInputPanel()
            {
                IntPtr TouchhWnd = new IntPtr(0);
                TouchhWnd = FindWindow("IPTip_Main_Window", null);
                if (TouchhWnd == IntPtr.Zero)
                    return;
                PostMessage(TouchhWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
            }
            //结束进程
            public void kill_key()
            {
                Form1 form = new Form1();
                var list2 = form.get_pressId("osk");


            }



        }

 

 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C#Tostring()方法发布时间:2022-07-13
下一篇:
C#字符串自增自减算法发布时间:2022-07-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap