zoukankan      html  css  js  c++  java
  • C# 挂起 进程 PostMessage使用

            #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");
    
    
                }
    
    
    
            }
    
    
    
     
  • 相关阅读:
    读TIJ -2 一切都是对象
    codeforces 437C The Child and Toy
    关于js基础easy忘记的那些事儿
    项目启动会应该注意的几点
    SSH-Struts(一)——基本原理
    公益代理-开发人员的福音
    【手打】LZW编码的C/C++实现
    tab group of firefox
    Sort Colors -- LeetCode
    Qt 学习之路:自定义事件
  • 原文地址:https://www.cnblogs.com/enych/p/12179801.html
Copyright © 2011-2022 走看看