国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > 綜合 > 正文

C#中鍵盤(pán)鉤子的使用(轉(zhuǎn))

2024-07-21 02:27:47
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
  • 本文來(lái)源于網(wǎng)頁(yè)設(shè)計(jì)愛(ài)好者web開(kāi)發(fā)社區(qū)http://www.html.org.cn收集整理,歡迎訪問(wèn)。
  • public class win32hook
    {

        [dllimport("kernel32")]
        public static extern int getcurrentthreadid();

        [dllimport( "user32",
    charset=charset.auto,callingconvention=callingconvention.stdcall)]
        public static extern int  setwindowshookex(
            hooktype idhook,
            hookproc lpfn,
            int hmod,
            int dwthreadid);

        public enum hooktype
        {
            wh_keyboard = 2
        }
        
    public delegate int hookproc(int ncode, int wparam, int    lparam);

        public void sethook()
        {
            // set the keyboard hook
            setwindowshookex(hooktype.wh_keyboard,
                new hookproc(this.mykeyboardproc),
                0,
                getcurrentthreadid());
        }

        public int mykeyboardproc(int ncode, int wparam, int lparam)
        {
            //在這里放置你的處理代碼        return 0;
        }
    }
    使用方法
    可以在form的構(gòu)造函數(shù)里放入
    win32hook hook = new win32hook();
    hook.sethook();



    發(fā)表評(píng)論 共有條評(píng)論
    用戶名: 密碼:
    驗(yàn)證碼: 匿名發(fā)表
    主站蜘蛛池模板: 福清市| 山阳县| 临潭县| 深圳市| 饶平县| 壤塘县| 荥阳市| 桦甸市| 香河县| 平谷区| 宁陵县| 岗巴县| 南投县| 九寨沟县| 贵德县| 新乡市| 崇明县| 陕西省| 志丹县| 伊春市| 长岛县| 浦县| 广州市| 宜阳县| 大冶市| 大同县| 黄大仙区| 广水市| 永仁县| 金川县| 大方县| 莲花县| 新巴尔虎左旗| 霞浦县| 原平市| 新建县| 子长县| 湘潭县| 深水埗区| 富阳市| 安图县|