tags:

views:

21

answers:

1

In MFC C++, When we add a new resourcein a EXE, says string, it will generate an ID automatically:

#define ID_SHOW_OUTPUT                 10313

When it has a plugin(DLL) which has the similar ID, it will cause undefined behavior after trigerred.

To play safe, I tried to define the my own private ID:

#define ID_SHOW_OUTPUT          (WM_APP+6)

However, I will have a lot of work if there are hundreds of resources in the EXE and DLL.

I'm not sure there is a better solution and prevention on duplicated resource ID across executables???

+1  A: 
  • Check this add-in. It gives you a higher control over resource ids.
  • As Luke commentd, there should not be problems using DLLs with duplicte resource ids. Only one resource module is active at a time using AfxSetResourceHandle
  • Setting Command IDs to arbitrary UINT values (In your question you assigned WM_APP + 6 to a command ID) is not safe since these values are interpreted by MFC in many places. Check this StackOverflow question for more details.
mmonem
The ResOrg recommended is indeed a cool tool. It will be perfect if it is able to load multiple Resource.h, from exe and dlls within the same process... Do you have seen this kind of tool?
wengseng