Recent units have a large number of images vectorized, time tight tasks, the numerous staff must set the graphics in addition to graphics, because the foreign software used, the property fills in the right-click menu is blocked, so numerous staff Ctrl V is required to operate the operational action for this keyboard for a large number of modes of operation, so it has written a global hook that can be pasted through the right-click, once the application, and the progress is improved. Many, and the number of modifications is relaxed, the following is the code written in VC6. Write this hook process has encountered some difficulties. I don't want other friends to encounter, so I will send a code. This code is modified according to the netizen code, thank you again for Lu Peipei (http://blog.9cbs.net/goodname008).
The global hook DLL is written by VC6, and the digitalization assistant is written by VB6.
Download compiled program: http://www.cjsdn.net/user/download/112563/rdpaster.rar
/ ************************************************** ******************* / / * File Name: mymousehook.cpp * // * * // * Function: Standard DLL ---- Using the mouse global hook implementation right click Double-click the paste function * // // * * * author: Rae (booolee) time: 2004.9.18 * // * * // * BLOG: http://blog.9cbs.net/booolee * // *** *********************************************************** *************** /
// Export function list // StartHook // stophook // About
#define _win32_winnt 0x0500 // Set the system version, make sure you can use the underlying mouse hook
#include "windows.h"
// Global variable hinstance g_hinstance = null; // module instance handle hHOOK G_HHHOOK = NULL; // hook handle
// the DLL entry function BOOL APIENTRY DllMain (HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {// save module instance handle g_hInstance = (HINSTANCE) hModule; unloading hook switch (ul_reason_for_call) // when the process ends or thread ends {case DLL_PROCESS_ATTACH : Break; Case DLL_THREAD_ATTACH: BREAK; CASE DLL_PROCESS_DETACH: CASE DLL_THREAD_DETACH: IF (g_hhook! = Null) UnHookWindowsHookex (g_hhook); Break;} returnography;
// bottom mouse hook function LRESULT CALLBACK MouseHookProc (int nCode, WPARAM wParam, LPARAM lParam) {LPMOUSEHOOKSTRUCT pMouseHook = (MOUSEHOOKSTRUCT FAR *) lParam; if (nCode> = 0) {if (wParam == WM_RBUTTONDBLCLK) {HWND glhTargetWnd = pMouseHook -> hwnd; if (glhTargetWnd = NULL!) {char * buffer = NULL; if (OpenClipboard (NULL)) {HANDLE hData = GetClipboardData (CF_TEXT); char * buffer = (char *) GlobalLock (hData); SetWindowText (glhTargetWnd , Buffer; GlobalUnlock (HDATA); CloseClipboard (); return true;}}}} // Transfer to the next hook Return CallNexThooKex (g_hhook, ncode, wparam, lparam);} / ****** *********************************************************** ************ / / * Install the mouse hook * /// * parameter: (none) * // * Return value: true success, False failed * // ******** *********************************************************** ********** / BOOL WINAPI STARTHOK () {// Returns false if (g_hhook! = Null) Return False; // Install the underlying mouse hook g_hook = setWindowshookex (Wh_mouse, MousehookProc G_HINSTANCE, NULL); if (g_hhook == null) Return False; MessageBox (NULL, "started!"
/ ************************************************** ******************* / / * Uninstall mouse hook * // * * // * parameter: (none) * // * * // * Return value: True Success, False failed * // ************************************************************** ********************************** / BOOL WINAPI StopHook () {// Uninstall Hook IF (UnHookWindowsHooKex (g_hhook == 0) Return False; g_hhook = NULL; MessageBox (NULL, "Uninstall Success!", "BOBO Mouse Double-click Pastel", MB_OK); Return True;
BOOL WINAPI About () {MessageBox (NULL, "Author: Rae / n Function: Double-click the right mouse button to paste operations / n Date: 2004.9.18 / n Mail: booolee@yahoo.com.cn", "on the mouse hook." , MB_OK); Return True;} **************************************************** ************************** / / * file name: mymousehook.h * // * * // * function: standard DLL export function header file, include this file in the program to use the DLL's * // // * * * author: Rae (booolee) time: 2004.9.18 * // * * // * BLOG: http: //blog.9cbs. Net / boolee * // ********************************************************************** *********************** /
DECLSPEC_IMPORTBOOLWINAPISTARTHOK ();
DECLSPEC_IMPORTBOOLWINAPISTOPMASKKEY ();
DECLSPEC_IMPORTBOOLWINAPIABOUT ();
Maskkey.def code is as follows
ExportsStarthook @ 1stophook @ 2about @ 3
Citing the statement of hooks in VB6
Declare Function Starthook Lib "MyMousehook" () AS Longdeclare Function StopHook LIB "MyMousehook" () AS Longdeclare Function About Lib "MyMousehook" () as long