(2)添加一个标准模块,命名为MOULDLE1,写入以下代码: Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long '在窗口结构中为指定的窗口设置信息 Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long '从指定窗口的结构中取得信息 Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long '运行指定的进程 Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal ID As Long, ByVal fsModifiers As Long, ByVal vk As Long) As Long '向系统注册一个指定的热键 Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As Long, ByVal ID As Long) As Long '取消热键并释放占用的资源 '上述五个API函数是注册系统级热键所必需的,具体实现过程如后文所示 Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long '本函数是实现隐藏的核心,参数HWND既是需要隐藏项目的句柄 'nCmdShow参数可以决定使隐藏还是显示 Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long '本函数得到当前鼠标所在位置的屏幕坐标 Public Declare Function WindowFromPointXY Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long '本函数根据屏幕坐标返回被隐藏项目的句柄 Public Type POINTAPI X As Long Y As Long End Type'鼠标坐标类型定义 Public Const SW_HIDE = 0'隐藏常数 Public Const SW_SHOW = 5'显示常数 Public Const WM_HOTKEY = &H312 '热键标志常数,用来判断当键盘按键被按下时是否命中了我们设定的热键 Public Const GWL_WNDPROC = (-4) Public preWinProc As Long, MyhWnd As Long,uVirtKey As Long '定义系统的热键,原中断标示,被隐藏的项目句柄 '请紧记下面的热键拦截函数,它将对你将来编写WINDOWS32高级控制程序大有帮助! Public Function Wndproc(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long '热键拦截过程 If Msg = WM_HOTKEY Then'如果拦截到热键标志常数 If wParam = 1 Then '如果是我们的定义的热键F12... '为了节省篇幅,我对热键拦截处理不是非常严密... hideDONE '执行隐藏鼠标所指项目 End If End If '如果不是热键,或者不是我们设置的热键,交还控制权给 '系统,继续监测热键 Wndproc = CallWindowProc(preWinProc, hwnd, Msg, wParam, lParam) End Function Public Sub hideDONE()'最关键的项目隐藏过程 Public Sub hideDONE() Dim pt32 As POINTAPI GetCursorPos pt32 ''得到鼠标屏幕坐标 MyhWnd = WindowFromPointXY(pt32.X, pt32.Y) ''得到所在位置窗体项目句柄 If MyhWnd = Chinahide.hwnd Then Exit Sub '拒绝隐藏程序自身 Chinahide.List1.AddItem (MyhWnd) ''添加相关信息 ShowWindow MyhWnd, SW_HIDE '执行隐藏功能 End Sub ‘模块结束 本文代码不仅将向编程爱好者展示“隐藏引擎”的魅力,也将让您立刻成为一个后台控制和系统级热键的编程高手。它适用于windows95/98/nt4/me/2000,vb5/6开发平台。 看到这里,你一定会想到能够将它应用到哪里了吧(譬如加个密码就可以保护你的桌面!)——心动不如行动,DO IT BY YOUSELF!  
2/2 首页 上一页 1 2 |