Avoid Resource Conflict
        Posted  
        
            by Yan Cheng CHEOK
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Yan Cheng CHEOK
        
        
        
        Published on 2010-06-17T09:36:04Z
        Indexed on 
            2010/06/17
            9:43 UTC
        
        
        Read the original article
        Hit count: 880
        
I have a MFC exe, trying to dynamic load a 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);
Both MFC exe and MFC dll, are having their own resource file.
However, I realize that, if MFC exe and MFC dll are having a same resource ID, conflict may occur.
// 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);
May I know how I can avoid resource ID conflict problem? Can we have two resource in both MFC and DLL, although their ID is different, but they are independent from each other?
This means, DLL will only load DLL's resource. EXE will only load EXE's resource.
© Stack Overflow or respective owner