外挂代码,编译出错,请教
编译下列程序时出错:// ActiverKey.cpp : Defines the initialization routines for the DLL.
//
#include "ActiveKey.h"
#include "stdafx.h"
#include <afxdllx.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static AFX_EXTENSION_MODULE ActiverKeyDLL = { NULL, NULL };
extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
// Remove this if you use lpReserved
UNREFERENCED_PARAMETER(lpReserved);
if(dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("NotePadHOOK.DLL Initializing!");
// Extension DLL one-time initialization
if (!AfxInitExtensionModule(ActiverKeyDLL, hInstance))
return 0;
// Insert this DLL into the resource chain
// NOTE: If this Extension DLL is being implicitly linked to by
// an MFC Regular DLL (such as an ActiveX Control)
// instead of an MFC application, then you will want to
// remove this line from DllMain and put it in a separate
// function exported from this Extension DLL. The Regular DLL
// that uses this Extension DLL should then explicitly call that
// function to initialize this Extension DLL. Otherwise,
// the CDynLinkLibrary object will not be attached to the
// Regular DLL's resource chain, and serious problems will
// result.
new CDynLinkLibrary(ActiverKeyDLL);
glhInstance = hInstance;
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("NotePadHOOK.DLL Terminating!");
// Terminate the library before destructors are called
AfxTermExtensionModule(ActiverKeyDLL);
}
return 1; // ok
}
//Shared data section
#pragma data_seg("shareddata")
int HHOOK glhHook = NULL;
HINSTANCE glhInstance = NULL;
#pragma data_seg()
extern "C" LRESULT WINAPI KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode >= 0)
{
if(wParam == 0X79)
{
CPoint newPoint, oldPoint;
GetCursorPos(&oldPoint);
newPoint.x = oldPoint.x+40;
newPoint.y = oldPoint.y+10;
int _cdecl SetCursorPos(newPoint.x, newPoint.y);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT, 0), 0, 0);
keybd_event(0x52, MapVirtualKey(0x52,0), 0, 0);
keybd_event(0x52, MapVirtualKey(0x52,0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT,0),KEYEVENTF_KEYUP, 0);
SetCursorPos(oldPoint.x, oldPoint.y);
}
}
return CallNextHookEx(glhHook, nCode, wParam, lParam);
}
CKeyHook::CKeyHook(){}
CKeyHook::~CKeyHook()
{
if(glhHook)
Stop();
}
HHOOK CKeyHook::Start()
{
glhHook = SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,glhInstance,0);
return glhHook;
}
BOOL CKeyHook::Stop()
{
BOOL bResult = TRUE;
if(glhHook)
int bResult = int _cdecl UnhookWindowsHookEx(glhHook);
return bResult;
}
错误提示:
--------------------Configuration: ActiverKey - Win32 Debug--------------------
Compiling...
ActiverKey.cpp
F:\练习\ActiverKey\ActiverKey.cpp(43) : error C2065: 'glhInstance' : undeclared identifier
F:\练习\ActiverKey\ActiverKey.cpp(43) : error C2440: '=' : cannot convert from 'struct HINSTANCE__ *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
F:\练习\ActiverKey\ActiverKey.cpp(56) : error C2146: syntax error : missing ';' before identifier 'glhHook'
F:\练习\ActiverKey\ActiverKey.cpp(56) : error C2377: 'HHOOK' : redefinition; typedef cannot be overloaded with any other symbol
e:\vc98\include\windef.h(196) : see declaration of 'HHOOK'
F:\练习\ActiverKey\ActiverKey.cpp(56) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
ActiverKey.dll - 1 error(s), 0 warning(s)
请予纠正!