mfc进阶3~未定义的标识符EDIT_FILE_IN

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/LH1963/article/details/52449449

添加了一个edit control,修改它的ID为EDIT_FILE_IN,又通过类向导,添加了和其相关联的控件变量m_editFileIn,结果程序自己加的这部分代码

DDX_Control(pDX, EDIT_FILE_IN, m_editFileIn);

出错,提示“未定义的标识符 EDIT_FILE_IN”


解决方法,DDX_Control所在的cpp中,添加头文件resource.h,就OK拉!

展开阅读全文

全局变量出现未定义标识符

05-22

用试验hook时发现一个已经定义了全局变量的变量,在dllmain.cpp中显示未定义标示符rn求大神解惑rnrndllmain.app中的代码rn[code=c]rnrn// dllmain.cpp : 定义 DLL 的初始化例程。rn//rnrn#include "stdafx.h"rn#include rn#include rnrn#ifdef _DEBUGrn#define new DEBUG_NEWrn#endifrnrnrnstatic AFX_EXTENSION_MODULE ActivityKeyDLL = NULL, NULL ;rnrnextern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)rnrn//如果使用lpReserved参数则删除下面这行rn UNREFERENCED_PARAMETER(lpReserved);rn if (dwReason == DLL_PROCESS_ATTACH)rn rn TRACE0("NOtePadHOOK.DLL Initializing!\n");rn //扩展DLL仅初始化一次rn if (!AfxInitExtensionModule(ActivityKeyDLL, hInstance))rn return 0;rn new CDynLinkLibrary(ActivityKeyDLL);rn //把DLL加入动态MFC类库中rn glhInstance=hInstance;//出错点提示glhInstance未定义标识符rn //插入保存DLL实例句柄rn rn else if (dwReason == DLL_PROCESS_DETACH)rn rn TRACE0("NotePadHOOK.DLL Terminating!\n");rn //终止这个链接库前调用它rn AfxTermExtensionModule(ActivityKeyDLL);rn rn return 1;rn[/code]rnrnrn主文件中的代码rn[code=c]rn// ActivityKey.cpp : 定义 DLL 的初始化例程。rn//rnrn#include "stdafx.h"rn#include "ActivityKey.h"rnrnrnrn#ifdef _DEBUGrn#define new DEBUG_NEWrn#endifrnrn//shared data section全局共享数据rn#pragma data_seg("sharedata")rnHHOOK glhHook=NULL; //钩子句柄。rnHINSTANCE glhInstance=NULL; //dll实例句柄。(此处申明了glhInstance变量)rn#pragma data_seg()rnrnrnextern "C" LRESULT WINAPI KeyboardProc(int nCode,WPARAM wParam,LPARAM lParam)rnrn if( nCode >= 0 )rn rn if( wParam == 0X79 )//当按下F10键时,激活外挂。rn rn //外挂实现代码。rn CPoint newPoint,oldPoint;rn GetCursorPos(&oldPoint);rn newPoint.x = oldPoint.x+40;rn newPoint.y = oldPoint.y+10;rn SetCursorPos(newPoint.x,newPoint.y);rn mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);//模拟按下鼠标左键。rn mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);//模拟放开鼠标左键。rn keybd_event(VK_SHIFT,MapVirtualKey(VK_SHIFT,0),0,0); //按下SHIFT键。rn keybd_event(0x52,MapVirtualKey(0x52,0),0,0);//按下R键。rn keybd_event(0x52,MapVirtualKey(0x52,0),KEYEVENTF_KEYUP,0);//放开R键。rn keybd_event(VK_SHIFT,MapVirtualKey(VK_SHIFT,0),KEYEVENTF_KEYUP,0);//放开SHIFT键。rn SetCursorPos(oldPoint.x,oldPoint.y);rn rn rn return CallNextHookEx(glhHook,nCode,wParam,lParam);rnrnrnCKeyHook::CKeyHook()rnrnrnrnrnCKeyHook::~CKeyHook()rnrn Stop();rnrnrn //install static hookrnBOOL CKeyHook::Start()rnrn BOOL bResult=FALSE;rn glhHook = SetWindowsHookEx(WH_KEYBOARD,KeyboardProc,glhInstance,0);//设置键盘钩子。rn if(glhHook!=NULL)rn bResult=TRUE;rn return bResult;rnrn //卸载全局钩子。rnBOOL CKeyHook::Stop()rnrn BOOL bResult = TRUE;rn if( glhHook )rn bResult = UnhookWindowsHookEx(glhHook);//卸载键盘钩子。rn return bResult;rnrn[/code] 论坛

没有更多推荐了,返回首页