如果你想要控制整个塌弯计算机,那得用动态链接库。做成一个全局的钩子
我之前写过,不小心把电脑全屏蔽了,只好强制关机,呵呵···
在程序的#include下面加上这么亏枣几句:__declspec(dllexport) void __stdcall SetHook(HWND hwnd)
__declspec(dllexport) void __stdcall UnHook()
__declspec(dllexport) CPoint __stdcall getPoint()
而腊咐且你直接返回CPoint在VB里面是无销局拆法识别的
#include <windows.h>#pragma data_seg("MySec")
HWND g_hnd=NULL
#pragma data_seg()
#pragma comment(linker,"/section:MySec,RWS")
HHOOK g_hmouse = NULL
HHOOK g_hkeyboard=NULL
//鼠标钩子过程函数
LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam)
{
return 1
}
LRESULT CALLBACK KeyboardProc(int code, WPARAM wParam, LPARAM lParam)
{
if (0x41==wParam &&(1==(lParam >>29 &1)))
{
SendMessage(g_hnd, WM_CLOSE,0,0)
UnhookWindowsHookEx(g_hmouse)
UnhookWindowsHookEx(g_hkeyboard)
}
return 1
}
//安装钩子函数
void SetHook(HWND hnd)
{
g_hnd=hnd
g_hmouse = SetWindowsHookEx(WH_MOUSE, MouseProc, GetModuleHandle("HOOk"),0)
g_hkeyboard = SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,GetModuleHandle("HOOk"),0)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)