【发布时间】:2010-06-17 09:36:04
【问题描述】:
我有一个 MFC exe,正在尝试动态加载 MFC dll。
// This is code in MFC exe
HINSTANCE h = AfxLoadLibrary(_T("DLL.dll"));
typedef void(*FUN)();
FUN fun = (FUN)GetProcAddress(h, "loveme");
FreeLibrary(h);
MFC exe 和 MFC dll 都有自己的资源文件。
但是,我意识到,如果 MFC exe 和 MFC dll 具有相同的资源 ID,则可能会发生冲突。
// This is code in MFC dll. Both exe and dll, are having resources with
// ID 101.
CString s;
s.LoadString(101);
// Resource 101 in exe is being shown :(
AfxMessageBox(s);
我可以知道如何避免资源 ID 冲突问题吗? MFC和DLL中可以有两个资源,虽然ID不同,但是相互独立?
这意味着,DLL 只会加载 DLL 的资源。 EXE 只会加载 EXE 的资源。
【问题讨论】: