| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 855 人关注过本帖
标题:外挂代码,编译出错,请教
只看楼主 加入收藏
gling66
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-4-21
收藏
 问题点数:0 回复次数:0 
外挂代码,编译出错,请教
编译下列程序时出错:
// 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)
请予纠正!
搜索更多相关主题的帖子: 代码 编译 外挂 
2010-05-12 09:51
快速回复:外挂代码,编译出错,请教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024387 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved