企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
1.创建dll工程 2.在dllmain.cpp中修改 ```c++ // dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "stdafx.h" HHOOK g_hHook = nullptr; HINSTANCE g_hInstance = nullptr; LRESULT CALLBACK HookFunc(int nCode ,WPARAM wParam,LPARAM lParam) { if (HC_ACTION != nCode)return 0; PMSG pMsg = (PMSG)lParam; if (!pMsg->message == WM_KEYDOWN)return 0; PostMessage(pMsg->hwnd,WM_CHAR,pMsg->wParam,pMsg->lParam); return CallNextHookEx(g_hHook,nCode,wParam,lParam); } //开始挂钩 //导入 extern "C" __declspec(dllexport) BOOL StartHook() { BOOL bRet = FALSE; g_hHook = SetWindowsHookEx(WH_GETMESSAGE,HookFunc,g_hInstance,NULL); if (!g_hHook)bRet = TRUE; return bRet; } BOOL UnHook() { return UnhookWindowsHookEx(g_hHook); } BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: g_hInstance = (HINSTANCE)hModule; break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: UnHook(); break; } return TRUE; } ```