win2000和xp

解决方案 »

  1.   

    你是想屏蔽任务管理器?
    在一个timer里不停的判断当前进程里是否有"taskmgr.exe",有则kill
      

  2.   

    re,SetWindowsHookEx,捕获WH_GETMESSAGE,CALLBACK里不return CallNextHookEx而返回1就是忽略该消息。
    自己判断一下。
      

  3.   

    关于键盘钩子我现在还没明白,曾经发帖子问没结果,
    也见过发同样帖子的人,都没解决.....
    多数只是告诉你,这是键盘钩子,hook........
    不过告诉你个不幸的消息,ctrl + alt + del 和 ctrl + shift + ESC 是一样的.....
    还有,简单的禁用任务管理器可以使用修改注册表.....
      

  4.   

    曾经发帖别人告诉我的,不过我没有用好,你可以借鉴一下
    注:别人的代码,非本人////C# codeusing System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;namespace 钩子
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void Form1_Load(object sender, EventArgs e)
            {
                SetHook();
            }        internal enum HookType
            {
                //msgfilter = -1,
                //journalrecord = 0,
                //journalplayback = 1,             Keyboard = 2,            //getmessage = 3,
                //callwndproc = 4,
                //cbt = 5,
                //sysmsgfilter = 6,
                //mouse = 7,
                //hardware = 8,
                //debug = 9,
                //shell = 10,
                //foregroundidle = 11,
                //callwndprocret = 12,
                //keyboardll = 13,         };
            IntPtr _nextHookPtr;    //记录hook编号 
            [DllImport("kernel32.dll")]
            static extern int GetCurrentThreadId();    //取得当前线程编号的API         [DllImport("user32.dll")]
            internal extern static void UnhookWindowsHookEx(IntPtr handle);  //取消hook的api         [DllImport("user32.dll")]
            internal extern static IntPtr SetWindowsHookEx(int idHook, [MarshalAs(UnmanagedType.FunctionPtr)] HookProc lpfn, IntPtr hinstance, int threadID);  //设置hook的api         [DllImport("user32.dll")]
            internal extern static IntPtr CallNextHookEx(IntPtr handle, int code, IntPtr wparam, IntPtr lparam);        internal delegate IntPtr HookProc(int code, IntPtr wparam, IntPtr lparam);
            IntPtr MyHookProc(int code, IntPtr wparam, IntPtr lparam)
            {
                if (code < 0)
                    return CallNextHookEx(_nextHookPtr, code, wparam, lparam);
                if (wparam.ToInt32() == 98 && wparam.ToInt32() == 66)
                {
                    this.textBox1.Text = "a";
                    return (IntPtr)1;
                }
                else
                {
                    return IntPtr.Zero;
                }
     
            }        public void SetHook()
            {
                if (_nextHookPtr != IntPtr.Zero)
                    return;            HookProc myhookProc = new HookProc(MyHookProc);
                _nextHookPtr = SetWindowsHookEx((int)HookType.Keyboard, myhookProc, IntPtr.Zero, GetCurrentThreadId());
            }
            public void UnHook()
            {
                if (_nextHookPtr != IntPtr.Zero)
                {
                    UnhookWindowsHookEx(_nextHookPtr);
                    _nextHookPtr = IntPtr.Zero;
                }
            }
            private void Form1_FormClosed(object sender, FormClosedEventArgs e)
            {
                UnHook();
            }
        }
    }
      

  5.   


    是不是那个  “namespace 钩子” 不能有中文呢??