我的系统:Windows 2000 + SP4、VC6 + SP6、Microsoft Platform SDK February 2003
然后在StdAfx.h里开头处打如下
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#ifdef WINVER
#undef WINVER
#endif
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
定义使用windows2000的操作系统,从而可以应用一些新的SDK
然后在OnNewDocument的时候执行如下代码
BOOL CSongManageDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
CString strPathName;
CString strFileName;
CFileDialog dlg(TRUE , "dbf" , NULL , OFN_FILEMUSTEXIST
, "DBF数据库文件(*.dbf)|*.dbf|所有文件(*.*)|*.*|" , NULL);
if(dlg.DoModal() != IDOK)
{
m_iOpen = 0;
return FALSE;
} strPathName = dlg.GetPathName();
strFileName = dlg.GetFileName();
return TRUE;
}编译通过后,执行新建文档操作,如常打开一个“打开文件对话框”,打开任意一个文件,即报错!
Unhandled exception in File Splitter.exe (KERNEL32.DLL): 0xC0000005: Access Violation搜索了一个Google,发现有个外国人也发现了这个问题,但是不了了之。。请看如下外国链接(速度比较慢):
http://tek-tips.com/viewthread.cfm?qid=815048
http://forums.devarticles.com/t7641/s.html?highlight=display+text+file+list+in+cfloop+containing+blank+spaces如果把stdafx.h里的定义_WIN32_WINNT 和 WINVER 取消,那么就十分正常,但是只要加上去,即报错!
谁能解决此问题,100分相送!!
然后在StdAfx.h里开头处打如下
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#ifdef WINVER
#undef WINVER
#endif
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
定义使用windows2000的操作系统,从而可以应用一些新的SDK
然后在OnNewDocument的时候执行如下代码
BOOL CSongManageDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
CString strPathName;
CString strFileName;
CFileDialog dlg(TRUE , "dbf" , NULL , OFN_FILEMUSTEXIST
, "DBF数据库文件(*.dbf)|*.dbf|所有文件(*.*)|*.*|" , NULL);
if(dlg.DoModal() != IDOK)
{
m_iOpen = 0;
return FALSE;
} strPathName = dlg.GetPathName();
strFileName = dlg.GetFileName();
return TRUE;
}编译通过后,执行新建文档操作,如常打开一个“打开文件对话框”,打开任意一个文件,即报错!
Unhandled exception in File Splitter.exe (KERNEL32.DLL): 0xC0000005: Access Violation搜索了一个Google,发现有个外国人也发现了这个问题,但是不了了之。。请看如下外国链接(速度比较慢):
http://tek-tips.com/viewthread.cfm?qid=815048
http://forums.devarticles.com/t7641/s.html?highlight=display+text+file+list+in+cfloop+containing+blank+spaces如果把stdafx.h里的定义_WIN32_WINNT 和 WINVER 取消,那么就十分正常,但是只要加上去,即报错!
谁能解决此问题,100分相送!!
if(hInst)
{
typedef BOOL (WINAPI *MYFUNC)(...); // 函数指针定义
MYFUNC fun = NULL;
fun=(MYFUNC)GetProcAddress(hInst, "..."); // 取得指针
if(fun)
fun(...);
FreeLibrary(hInst);
}
Windows 2000 S+ SP3、VC6 、Microsoft Platform SDK February 2003复制你的代码运行都好像没什么问题
谢谢你的提议。。但这毕竟不是治本之法。
to DeadWolf:
可能你没有庄vc6sp6
to Mackz:
我都看过了。。多了三个参数,那应该怎样?
CString sFilter="jpeg文件(*.jpg)|*.jpg|bmp文件(*.bmp)|*.bmp|GIF文件(*.gif)|*.gif||";
#undef _WIN32_WINNT
#endif
#ifdef WINVER
#undef WINVER
#endif
#define _WIN32_WINNT 0x0500
#define WINVER 0x0500
我以前也碰到过和你一样的问题。
我解决的方法是直接用api解决的,不用CFileDialog
CFileDialog *dlg = new CFileDialog(TRUE , "dbf" , NULL , OFN_FILEMUSTEXIST,
"DBF数据库文件(*.dbf)|*.dbf|所有文件(*.*)|*.*|" ,this);
dlg->m_ofn.lStructSize = sizeof(OPENFILENAME);
if(dlg->DoModal() != IDOK)
{
return;
}
strPathName = dlg->GetPathName();
strFileName = dlg->GetFileName();
delete dlg;
这句没必要,是设定2000风格的。
CFileDialog *dlg = new CFileDialog(TRUE , "dbf" , NULL , OFN_FILEMUSTEXIST,
"DBF数据库文件(*.dbf)|*.dbf|所有文件(*.*)|*.*|" ,this);
dlg->m_ofn.lStructSize = sizeof(OPENFILENAME);
if(dlg->DoModal() != IDOK)
{
delete dlg;
return;
}strPathName = dlg->GetPathName();
strFileName = dlg->GetFileName();
delete dlg;
我的系统配置和你的一样。呵呵。
CFileDialog dlg(TRUE , "dbf" , NULL , OFN_FILEMUSTEXIST
, "DBF数据库文件(*.dbf)|*.dbf|所有文件(*.*)|*.*|" , NULL);
改为:
CFileDialog dlg(TRUE , "dbf" , NULL , OFN_FILEMUSTEXIST
, "DBF数据库文件(*.dbf)|*.dbf|所有文件(*.*)|*.*|" , NULL, sizeof (OPENFILENAME) );
试试
dwSize
The size of the OPENFILENAME structure. This value is dependent on the operating system version, so MFC can determine the appropriate kind of dialog to create (for example, new Windows 2000 dialogs as opposed to NT4 dialogs).
#if _WIN32_WINNT >= 0x0500
#undef _WIN32_WINNT
#endif
这样做"DBF数据库文件(*.dbf)|*.dbf|所有文件(*.*)|*.*|"
改成
"DBF数据库文件(*.dbf)|*.dbf|所有文件(*.*)|*.*||"
-----------------------------------------------------------
结束时是两个||,而不是一个|