开发者

How to prevent duplicated resource ID in different plugins?

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 bet开发者_StackOverflow社区ter solution and prevention on duplicated resource ID across executables???


  • Check this add-in. It gives you a higher control over resource ids.

  • As Luke commented, 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜