【发布时间】:2014-05-03 15:55:14
【问题描述】:
我真的很想使用 MFC 的一些功能,但是开始工作很痛苦。
我最初想做的只是添加两个旋转控件和它们各自的编辑控件。一旦我实现了他们适当的方法来设置 Range,我发现我需要使用 MFC。
所以 VS 抱怨没有 MFC。所以我去项目属性并添加使用 MFC 共享 DLL。运行它,崩溃! Win32Project1.exe 中 0x5964D8D2 (mfc120ud.dll) 处未处理的异常:0xC0000005:访问冲突读取位置 0x00000000
所以我尝试了静态,错误!很多链接器错误,要列出很多。
所以我回到了共享。错误发生在这个区域。
/////////////////////////////////////////////////////////////////////////////
// export WinMain to force linkage to this module
extern int AFXAPI AfxWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine, int nCmdShow);
extern "C" int WINAPI
_tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine, int nCmdShow)
#pragma warning(suppress: 4985)
{
// call shared/exported WinMain
return AfxWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}
最后一个箭头 }
Locals 用 +
将 hInstance 的值显示为红色
hInstance 0x000d0000 {Win32Project1.exe!_IMAGE_DOS_HEADER ImageBase} {unused=9460301 } HINSTANCE *
在 lpCmdLine + lpCmdLine 0x00831f8c L"" wchar_t *
这超出了我的调试专业知识,坦率地说,我会考虑另一种不使用 MFC 的旋转框的替代方案,但我似乎越来越需要 MFC,因为我想包含更多功能,所以它让 MFC 工作会很好,但它似乎也更脆弱。也许对像我这样的粗鲁程序员很敏感。
我想知道#includes 是否可能是导致此错误的原因?无论是订单?还是缺少?
这是我目前在 stdafx.h 中的内容
#pragma once
#pragma comment ( lib, "user32.lib" )
#pragma comment ( lib, "comctl32.lib" )
#pragma comment ( lib, "winmm.lib")//to play audio
#pragma comment(linker,"\"/manifestdependency:type='win32' \
name='Microsoft.Windows.Common-Controls' version='6.0.0.0' \
processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#include "targetver.h"
//#include <WinSDKVer.h>
//#include <afxwin.h>
#include <afxcmn.h>//for spinControl
#include <Afx.h>
#include <stdio.h>
#include <tchar.h>
#include "iostream"
#include "string.h"
#include <math.h>
//#include <ctime>//more time related stuff
#include <fstream>//for file io
#include <thread>//for threads
//#include <chrono> //for time related stuff
//#include <windows.h>
#include <Mmsystem.h>//to play audio
#include <commctrl.h>
#include <atlstr.h>//for some type of string
#include <io.h>
#include <fcntl.h>
#include <commctrl.h> //For button sytles, maybe other styles
【问题讨论】:
标签: c++ mfc linker visual-studio-2013 access-violation