我可以成功编译,但是当我运行程序时,它会抛出一个错误,告诉我一个DLL不存在。经过试错,我确定程序在寻找“ROGRAM FILES\FolderName\rrpd.dll”中的DLL,显然截断了文件夹的前四个字符。
这是一个名为R&R Report Writer的应用程序,已经存在25多年,以前从未出现过这个问题。
调试后,我确定错误来自程序模块EXPLMGR.CPP(显式库管理器)中的赋值语句:
具体来说,从底部向上数第四行:
这是一个名为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 ;
}
具体来说,从底部向上数第四行:
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"
有没有什么方法来解决这个问题?我可以提供哪些额外的信息?