15,440
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include "Shi_Lu.h"
#include "SLCQGame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
SLCQGame *p=NULL;
BEGIN_MESSAGE_MAP(CShi_LuApp, CWinApp)
END_MESSAGE_MAP()
CShi_LuApp::CShi_LuApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
// The one and only CShi_LuApp object
CShi_LuApp theApp;
CShi_LuApp::ExitInstance()
{
delete p;
CWinApp::ExitInstance();
return 1;
}
LRESULT CALLBACK KeyboardProc( int nCode, WPARAM wParam, LPARAM lParam)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if((wParam == VK_F5)&&((lParam&(1<<31))==0))
{
if(p==NULL)
{
p=new SLCQGame;
p->Create(IDD_DIALOG_SLGAME);
}
p->ShowWindow(SW_SHOW);
}
return CallNextHookEx(NULL,nCode,wParam,lParam);
}
void SetHook()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
HWND hwnd=::FindWindow(NULL,"SRO_Client");
if(!hwnd)
{
AfxMessageBox("游戏未运行");
return;
}
DWORD Tid,Pid;
Tid=GetWindowThreadProcessId(hwnd,&Pid);
SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,GetModuleHandle("Shi_Lu.dll"),Tid);
}
__declspec (dllimport) void SetHook();
#pragma comment(lib,"Shi_Lu.lib")
void CMyDlg::OnButton1()
{
// TODO: Add your control notification handler code here
SetHook();
}