3

我可以成功编译,但是当我运行我的程序时,它会抛出一个错误,告诉我 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"

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

4

1 回答 1

0

事实证明,在尝试使程序兼容 64 位时,CFileStatus 结构中的 m_size 元素从 AFX.H 文件中的 LONG 更改为 ULONGLONG。这个问题在几个版本中都处于休眠状态,但最终在最近的版本中爆发了。不知道为什么。无论如何,我将声明改回 LONG 并且它现在似乎工作正常。

于 2013-05-07T22:12:51.303 回答