一次,一个MFC标准dll,在VC6的setting中,把D版的Dll更名输出,然后采用不同版链接不同dll,如下
//编译dll时设定_DLL_LTimeCount
#if !defined(_DLL_LTimeCount) && !defined(_JKSLTimeCount_MANUALLOAD) && !defined(_JKSALLDLLS_MANUALLOAD)
#ifdef _DEBUG
#pragma comment(lib,"LTimeCountD.lib")//对应LTimeCountD.dll
#pragma message("LTimeCountD.lib is linked./n")
#else
#pragma comment(lib,"LTimeCount.lib")//对应LTimeCount.dll
#pragma message("LTimeCount.lib is linked./n")
#endif
#define _JKSLTimeCount_MANUALLOAD
#endif
但是发现居然每次链接的都是 LTimeCount.dll,不管是R版还是D版
然而Win32 DLL就没有这个问题
经过分析发现,是由于MFC DLL工程中自动生成了一个def文件,其中指定了DLL的名称,
所以只要把这行屏蔽了就行了。如下
; LTimeCount.def : Declares the module parameters for the DLL.
;LIBRARY "LTimeCount" //屏蔽这一行
DESCRIPTION 'LTimeCount Windows Dynamic Link Library'
EXPORTS
; Explicit exports can go here