简体   繁体   中英

MFC application crashes on Windows XP

I have a very strange problem with my MFC application. Details:

  • Built with Microsoft Visual Studio 2008 (Version 9.0.30729.1 SP) under Windows Vista SP1 Ultimate.

This app. is about 15 years old and has seen most VS versions.

I have a separate test-pc with: Windows XP Pro SP3, Vista Home Premium, 7 Ultimate.

Of course I installed the VC++ redistributable on all Windows.

Now I will try to describe the problem:

The program uses MFC classes for working with CArchive objects. 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. This project can be saved to disk: MySheet.K01, MySheet.K02, etc. The sheets are viewed with a 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().

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.

I have ruled out the possibility that it matters if the program is compiled under 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"

Obviously...

It crashes when run from the IDE on XP? What crash do you get? Does it crash in Debug and Release versions?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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