#include "stdafx.h"
#include <afx.h>
#include <afxwin.h>
#include <afxext.h>
#include <afxdtctl.h>
#include <afxdlgs.h>int _tmain(int argc, _TCHAR* argv[])
{
CFileDialog dlg(true,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER);
return 0;
}
这是源程序,我只是打开一个文件对话框
uafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) 已经在 LIBCMT.lib(delete.obj) 中定义
atlsd.lib(atltime.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(Allocate.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(AtlTraceModuleManager.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(AtlDebugAPI.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(atlfuncs.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(atlbase.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(ATLComTime.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
uafxcwd.lib(oledisp1.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
uafxcwd.lib(filest.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
uafxcwd.lib(oletyplb.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(Externs.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
uafxcwd.lib(filecore.obj) : error LNK2019: 无法解析的外部符号 __CrtDbgReportW,该符号在函数 "void __stdcall _AfxFillExceptionInfo(class CFileException *,wchar_t const *)" (?_AfxFillExceptionInfo@@YGXPAVCFileException@@PB_W@Z) 中被引用
uafxcwd.lib(docmgr.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
.........................这要怎么修改呢?
#include <afx.h>
#include <afxwin.h>
#include <afxext.h>
#include <afxdtctl.h>
#include <afxdlgs.h>int _tmain(int argc, _TCHAR* argv[])
{
CFileDialog dlg(true,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER);
return 0;
}
这是源程序,我只是打开一个文件对话框
uafxcwd.lib(afxmem.obj) : error LNK2005: "void __cdecl operator delete(void *)" (??3@YAXPAX@Z) 已经在 LIBCMT.lib(delete.obj) 中定义
atlsd.lib(atltime.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(Allocate.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(AtlTraceModuleManager.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(AtlDebugAPI.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(atlfuncs.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(atlbase.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(ATLComTime.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
uafxcwd.lib(oledisp1.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
uafxcwd.lib(filest.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
uafxcwd.lib(oletyplb.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
atlsd.lib(Externs.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
uafxcwd.lib(filecore.obj) : error LNK2019: 无法解析的外部符号 __CrtDbgReportW,该符号在函数 "void __stdcall _AfxFillExceptionInfo(class CFileException *,wchar_t const *)" (?_AfxFillExceptionInfo@@YGXPAVCFileException@@PB_W@Z) 中被引用
uafxcwd.lib(docmgr.obj) : error LNK2001: 无法解析的外部符号 __CrtDbgReportW
.........................这要怎么修改呢?
控制台只能用API或STL
BOOL GetOpenFileName(LPOPENFILENAME lpofn);
CFileDialog dlg(true,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER);
dlg.DoModal();不过你在创建控制台程序的时候要设置支持MFC
还有就是,工程设置里,程序库那里要选 使用共享MFC dll这一项
#include <afx.h>
#include <afxwin.h>
#include <afxext.h>
#include <afxdtctl.h>
#include <afxdlgs.h>int _tmain(int argc, _TCHAR* argv[])
{
AfxSetResourceHandle(GetModuleHandle(NULL));
CFileDialog dlg(true,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER);
if (dlg.DoModal() == IDOK)
return -1;
return 0;
}
{
// TODO: 更改错误代码以符合您的需要
_tprintf(_T("致命错误: MFC 初始化失败\n"));
nRetCode = 1;
}
else
{
// TODO: 在此处为应用程序的行为编写代码。
}
控制台当然支持mfc,但不是全部的mfc类都支持,比如gdi相关的api就不能用