LoadString(nID) Problem and Solution

CString::LoadString(UINT nID)
Conclusion: the correct way to load string resource by ID is to call CString::LoadString(HINSTANCE hInstance,UINT nID), specifying the dll handler you want to search for.

Problem
CString::LoadString(UINT nID) will first use the instance handle of the main application to search for a string with the given ID. Failing that, it will look in DLLs in the order they were loaded until there is a match. If DLL A is loaded, then B and C, calling LoadString from DLL C will first find a matching resource in DLL A before finding its own resource.

Solution
Use CString::LoadString(HINSTANCE hInstance,UINT nID) or ::LoadString() function.
Another seem-to-work way (not suggested):
CString strTemp;
AFX_MANAGE_STATE(AfxGetStaticModuleState());
strTemp.LoadString(uID);

你可能感兴趣的:(String)