gpt4 book ai didi

c++ - 赋值语句截断字符

转载 作者:太空狗 更新时间:2023-10-29 23:17:50 24 4
gpt4 key购买 nike

<分区>

我可以成功编译,但是当我去运行我的程序时,它抛出一个错误告诉我一个 DLL 不存在。经过反复试验,我确定该程序正在寻找“ROGRAM FILES\FolderName\rrpd.dll”中的 DLL,显然截断了文件夹的前四个字符。

这适用于名为 R&R Report Writer 的应用程序,该应用程序已经存在 25 年以上并且以前从未遇到过此问题。

调试,我确定错误来自程序模块EXPLMGR.CPP(显式库管理器)中的赋值语句:

CString CExplicitLibraryManager::FindLocalDllFile(CString csDllName) const
{
ASSERT( csDllName.Find('\\') == -1 ); // These names should not have directory stuff.
// Search for the file in the program directory directory.
// If not found there, search in the registry system.
// If not found in either location, just return the file name.
CString csDllPath = m_csAppDirectory + csDllName ;
BOOL bDllExists = DoesFileExist ( csDllPath ) ; // Don't bother calling DoesDllExist(). A path is provided.
if ( !bDllExists )
{
csDllPath = m_csRrSystemDirectory + csDllName ;
bDllExists = DoesFileExist ( csDllPath ) ;
if ( !bDllExists )
{
// Must call the FindWindowsFile() here so that we can guarentee to return the full pathname.
csDllPath = FindWindowsFile ( csDllName ) ;
bDllExists = DoesFileExist ( csDllPath ) ;
}
}
if ( bDllExists )
{
CFileStatus fsFile ;
CFile::GetStatus ( csDllPath, fsFile ) ;
//TRACE( "CExplicitLibraryManager::FindLocalDllFile() Reports the DLL to be %s\n", fsFile.m_szFullName ) ;

csDllPath = fsFile.m_szFullName ;
}
return csDllPath ;
}

具体来说,从底部向上第 4 行:

csDllPath = fsFile.m_szFullName ;

此时fsFile.m_szFullName就是“C:\PROGRAM FILES\FolderName\rrpd.dll”,csDllPath也是一样。

调试并按下 [F11],作业直接进入

c:\program files\Microsoft visual studio\vc98\mfc\src\strcore.cpp

部分是:

const CString& CString::operator=(LPCTSTR lpsz)
{
ASSERT(lpsz == NULL || AfxIsValidString(lpsz));
AssignCopy(SafeStrlen(lpsz), lpsz);
return *this;
}

立即,如果我将鼠标悬停在 lpsz 上,它的值现在是

"rogram files\FolderName\rrpd.dll"

有什么办法可以解决这个问题吗?我可以提供哪些额外信息?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com