积极答复者
求助……生成程序时总是触发中断

问题
-
我是一个C++初学者,最近想练习做一个文件管理器,以下是函数InitPath(void)的代码
////////////////////////////////////////////////////////////////////////
//函数名称:InitPath
//函数功能:初始化逻辑分区,仅关心硬盘分区
//参数:无
//返回值:无
///////////////////////////////////////////////////////////////////////
void CFileDlg::InitPath(void)
{
wchar_t *pLogicalDrivers = new wchar_t[MAX_PATH];//申请用于存储结果的缓冲区pLogicalDrivers[0] = '\0';//初始化为空字符
int nLen = GetLogicalDriveStrings(MAX_PATH-1,pLogicalDrivers);//获取逻辑分区列表if (0==nLen)
{
//无结果则退出函数
return;
}
int nDriverNameLength = wcslen(L"C:\\") + 1;//格式设定int i = 0;
//在IDC_TREE_DIRECTORIES显示结果
TVINSERTSTRUCT tvInsertItem;
tvInsertItem.hParent = NULL;
tvInsertItem.hInsertAfter = NULL;
tvInsertItem.item.mask = TVIF_TEXT;
do
{
tvInsertItem.item.pszText = pLogicalDrivers+i;
m_tcDirectories.InsertItem(&tvInsertItem);//目录树中增加逻辑分区
i+=nDriverNameLength;
}while(i<nLen);
delete [] pLogicalDrivers;//回收缓冲区
}
每次断点调试到粗体字部分的代码时都会提示触发中断,要终止程序。还有生成解决方案的时候有时候会提示LINK : fatal error LNK1000: Internal error during IncrBuildImage再次生成解决方案显示成功,以下是生成日志,希望各位前辈能指点一二,学生不胜感激……
生成日志 重新生成 已启动: 项目: File,配置: Debug|Win32
命令行 正在创建临时文件“c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\RSP00002954441792.rsp”,其内容为 [ /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_AFXDLL" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Yu"stdafx.h" /Fp"Debug\File.pch" /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP ".\FileDlg.cpp" ".\File.cpp" ] 正在创建命令行“cl.exe @"c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\RSP00002954441792.rsp" /nologo /errorReport:prompt” 正在创建临时文件“c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\RSP00002A54441792.rsp”,其内容为 [ /Od /D "WIN32" /D "_WINDOWS" /D "_DEBUG" /D "_AFXDLL" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Yc"stdafx.h" /Fp"Debug\File.pch" /Fo"Debug\\" /Fd"Debug\vc90.pdb" /W3 /c /ZI /TP ".\stdafx.cpp" ] 正在创建命令行“cl.exe @"c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\RSP00002A54441792.rsp" /nologo /errorReport:prompt” 正在创建命令行“rc.exe /d "_DEBUG" /d "_AFXDLL" /d "_UNICODE" /d "UNICODE" /l 0x804 /I "Debug" /fo"Debug/File.res" ".\File.rc"” 正在创建临时文件“c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\TMP00002B54441792.tmp”,其内容为 [ 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ ".\\Debug\\File.exe.embed.manifest" ] 正在创建命令行“rc.exe /fo".\Debug\File.exe.embed.manifest.res" "c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\TMP00002B54441792.tmp"” 正在创建临时文件“c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\RSP00002C54441792.rsp”,其内容为 [ /OUT:"C:\Users\vv\Documents\Visual Studio 2008\Projects\File\Debug\File.exe" /INCREMENTAL /MANIFEST /MANIFESTFILE:"Debug\File.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\vv\Documents\Visual Studio 2008\Projects\File\Debug\File.pdb" /SUBSYSTEM:WINDOWS /ENTRY:"wWinMainCRTStartup" /DYNAMICBASE /NXCOMPAT /MACHINE:X86 ".\Debug\File.obj" ".\Debug\FileDlg.obj" ".\Debug\stdafx.obj" ".\Debug\File.res" ".\Debug\File.exe.embed.manifest.res" ] 正在创建命令行“link.exe @"c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\RSP00002C54441792.rsp" /NOLOGO /ERRORREPORT:PROMPT” 正在创建临时文件“c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\RSP00002D54441792.rsp”,其内容为 [ /out:".\Debug\File.exe.embed.manifest" /notify_update /manifest ".\Debug\File.exe.intermediate.manifest" ] 正在创建命令行“mt.exe @"c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\RSP00002D54441792.rsp" /nologo” 正在创建临时文件“c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\BAT00002E54441792.bat”,其内容为 [ @echo 清单资源上次更新时间为 %TIME%,更新位置为 %DATE% > ".\Debug\mt.dep" ] 正在创建命令行“""c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\BAT00002E54441792.bat""” 正在创建临时文件“c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\TMP00002F54441792.tmp”,其内容为 [ 1 /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ 24 /* RT_MANIFEST */ ".\\Debug\\File.exe.embed.manifest" ] 正在创建命令行“rc.exe /fo".\Debug\File.exe.embed.manifest.res" "c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\TMP00002F54441792.tmp"” 正在创建临时文件“c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\RSP00003054441792.rsp”,其内容为 [ /OUT:"C:\Users\vv\Documents\Visual Studio 2008\Projects\File\Debug\File.exe" /INCREMENTAL /MANIFEST /MANIFESTFILE:"Debug\File.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"c:\Users\vv\Documents\Visual Studio 2008\Projects\File\Debug\File.pdb" /SUBSYSTEM:WINDOWS /ENTRY:"wWinMainCRTStartup" /DYNAMICBASE /NXCOMPAT /MACHINE:X86 ".\Debug\File.obj" ".\Debug\FileDlg.obj" ".\Debug\stdafx.obj" ".\Debug\File.res" ".\Debug\File.exe.embed.manifest.res" ] 正在创建命令行“link.exe @"c:\Users\vv\Documents\Visual Studio 2008\Projects\File\File\Debug\RSP00003054441792.rsp" /NOLOGO /ERRORREPORT:PROMPT”
输出窗口 正在编译... stdafx.cpp 正在编译... File.cpp FileDlg.cpp c:\users\vv\documents\visual studio 2008\projects\file\file\filedlg.cpp(220) : warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. e:\study\visual studio\vc\include\string.h(252) : 参见“wcscpy”的声明 c:\users\vv\documents\visual studio 2008\projects\file\file\filedlg.cpp(221) : warning C4996: 'wcscat': This function or variable may be unsafe. Consider using wcscat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. e:\study\visual studio\vc\include\string.h(245) : 参见“wcscat”的声明 c:\users\vv\documents\visual studio 2008\projects\file\file\filedlg.cpp(226) : warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. e:\study\visual studio\vc\include\string.h(252) : 参见“wcscpy”的声明 c:\users\vv\documents\visual studio 2008\projects\file\file\filedlg.cpp(227) : warning C4996: 'wcscat': This function or variable may be unsafe. Consider using wcscat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. e:\study\visual studio\vc\include\string.h(245) : 参见“wcscat”的声明 c:\users\vv\documents\visual studio 2008\projects\file\file\filedlg.cpp(228) : warning C4996: 'wcscat': This function or variable may be unsafe. Consider using wcscat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. e:\study\visual studio\vc\include\string.h(245) : 参见“wcscat”的声明 c:\users\vv\documents\visual studio 2008\projects\file\file\filedlg.cpp(229) : warning C4996: 'wcscpy': This function or variable may be unsafe. Consider using wcscpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. e:\study\visual studio\vc\include\string.h(252) : 参见“wcscpy”的声明 c:\users\vv\documents\visual studio 2008\projects\file\file\filedlg.cpp(237) : warning C4996: 'wcscat': This function or variable may be unsafe. Consider using wcscat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. e:\study\visual studio\vc\include\string.h(245) : 参见“wcscat”的声明 正在生成代码... 正在编译资源... Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0 Copyright (C) Microsoft Corporation. All rights reserved. 正在编译资源清单... Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0 Copyright (C) Microsoft Corporation. All rights reserved. 正在链接... LINK : 没有找到 C:\Users\vv\Documents\Visual Studio 2008\Projects\File\Debug\File.exe 或上一个增量链接没有生成它;正在执行完全链接 正在嵌入清单... Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0 Copyright (C) Microsoft Corporation. All rights reserved. LINK : fatal error LNK1000: Internal error during IncrBuildImage Version 9.00.21022.08 ExceptionCode = C0000005 ExceptionFlags = 00000000 ExceptionAddress = 000DFCF7 (00060000) "E:\study\Visual Studio\VC\bin\link.exe" NumberParameters = 00000002 ExceptionInformation[ 0] = 00000000 ExceptionInformation[ 1] = 010BD670 CONTEXT: Eax = 400C894C Esp = 0027F134 Ebx = 40008164 Ebp = 0027F15C Ecx = 010BD670 Esi = 400C87DC Edx = 0027F14C Edi = 0006D6C0 Eip = 000DFCF7 EFlags = 00010246 SegCs = 0000001B SegDs = 00000023 SegSs = 00000023 SegEs = 00000023 SegFs = 0000003B SegGs = 00000000 Dr0 = 00000000 Dr3 = 00000000 Dr1 = 00000000 Dr6 = 00000000 Dr2 = 00000000 Dr7 = 00000000
答案
-
m_tcDirectories.InsertItem(&tvInsertItem);这句是循环第一次就出错还是运行到最后出错?
麻烦把正确答案设为解答。- 已标记为答案 VisualElevenModerator 2011年12月21日 2:30
全部回复
-
m_tcDirectories.InsertItem(&tvInsertItem);这句是循环第一次就出错还是运行到最后出错?
麻烦把正确答案设为解答。- 已标记为答案 VisualElevenModerator 2011年12月21日 2:30