简体   繁体   English

MFC应用程序在Windows XP上崩溃

[英]MFC application crashes on Windows XP

I have a very strange problem with my MFC application. 我的MFC应用程序有一个非常奇怪的问题。 Details: 细节:

  • Built with Microsoft Visual Studio 2008 (Version 9.0.30729.1 SP) under Windows Vista SP1 Ultimate. 在Windows Vista SP1 Ultimate下使用Microsoft Visual Studio 2008(版本9.0.30729.1 SP)构建。

This app. 这个程序。 is about 15 years old and has seen most VS versions. 大约15岁,已经看过大多数VS版本。

I have a separate test-pc with: Windows XP Pro SP3, Vista Home Premium, 7 Ultimate. 我有一个单独的测试计算机,其中包括:Windows XP Pro SP3,Vista Home Premium,7 Ultimate。

Of course I installed the VC++ redistributable on all Windows. 当然,我在所有Windows上都安装了可再发行的VC ++。

Now I will try to describe the problem: 现在,我将尝试描述问题:

The program uses MFC classes for working with CArchive objects. 该程序使用MFC类来处理CArchive对象。 A user can create a new project that contains one or more sheets that contain cells that may contain text, pictures, or both. 用户可以创建一个新项目,该项目包含一个或多个工作表,这些工作表包含可能包含文本,图片或两者的单元格。 eg a sheet with an 8x8 grid. 例如带有8x8网格的工作表。 This project can be saved to disk: MySheet.K01, MySheet.K02, etc. The sheets are viewed with a CMultiDocTemplate. 可以将项目保存到磁盘:MySheet.K01,MySheet.K02等。使用CMultiDocTemplate查看工作表。

I created a branch of this project for creating a program that can convert these files to another format. 我创建了该项目的一个分支,用于创建可以将这些文件转换为另一种格式的程序。 I made it a console application using AllocConsole(). 我使用AllocConsole()使其成为控制台应用程序。

When I test the program, the results are that it works fine on Windows 7, partially under Windows Vista and nothing but crashes on Windows XP. 当我测试该程序时,结果是它可以在Windows 7上正常运行,部分在Windows Vista下运行,而在Windows XP上则完全崩溃。

I have ruled out the possibility that it matters if the program is compiled under Windows XP. 我已经排除了该程序是否在Windows XP下编译的可能性。

Here is what I think is what is going wrong: 我认为这是出了什么问题:

CFile   myFile;
CMyDoc    *pDoc = (CMyDoc *)m_pDocViewTemplate->CreateNewDocument(); // Get a CDocument and cast it
CFileException myError;
TCHAR   *arcFileName = new TCHAR[MAX_PATH];

BOOL bTmp = myFile.Open(arcFileName, CFile::modeRead, &myError);
char lpszError[1024];
myError.GetErrorMessage(lpszError, 1024, 0);
_cprintf(lpszError);
_cprintf("\n");
if(!bTmp)
{
 _cprintf("ERROR: Unable to open the file!\n");
 return;
}

myFile.SeekToBegin();
CArchive myArc(&myFile, CArchive::load, 8192, 0);
myArc.m_bForceFlat = TRUE;
myArc.m_pDocument = pDoc;

pDoc->Serialize(myArc);

I am really at a loss here. 我真的很茫然。 I can provide more details if needed. 如果需要,我可以提供更多详细信息。

Thanks in advance. 提前致谢。

arcFileName will contain something like: "C:\\MyProject\\MySheet.K01" arcFileName将包含类似以下内容:“ C:\\ MyProject \\ MySheet.K01”

Obviously... 明显...

It crashes when run from the IDE on XP? 从XP上的IDE运行时会崩溃吗? What crash do you get? 您会遇到什么崩溃? Does it crash in Debug and Release versions? 在Debug和Release版本中会崩溃吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM