How to Edit Windows CE Binary Resource Files


Sometimes it is necessary to edit binary resources files (.res), for example to resize a dialog box, to disable a control, etc. Almost every MS IDE can open .res file and show all the resources in a graphic layout editor allowing the programmer to immediately check the result of the changes (there’s a good post about this topic on Bruce Eitman’s blog). Unfortunatly, the IDE resource formatting is slightly different from the one used in Windows CE resource script file (.rc) files and this can lead to subtle and annoying problems when you link the modified .res file to executable module: for example you click on a button and the dialog is not opened…
One possible solution is the following:

  • Open the .res file with the IDE
  • Modify it
  • Save the modified file as a resource script file (.rc)
  • Open the saved .rc file with a text editor
  • Remove the references to MFC and language, i.e.
    • At the beginning of the file:

 

#define APSTUDIO_READONLY_SYMBOLS///////////////////////////////////////////////////////////////////////////////// Generated from the TEXTINCLUDE 2 resource.//#include "afxres.h"/////////////////////////////////////////////////////////////////////////////#undef APSTUDIO_READONLY_SYMBOLS/////////////////////////////////////////////////////////////////////////////// English (U.S.) resources#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)#ifdef _WIN32LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US#pragma code_page(1252)#endif //_WIN32
  •  
    •  At the end of the file:

 

#endif // English (U.S.) resources//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// English (U.K.) resources#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)#ifdef _WIN32LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK#pragma code_page(1252)#endif //_WIN32#ifdef APSTUDIO_INVOKED///////////////////////////////////////////////////////////////////////////////// TEXTINCLUDE//1 TEXTINCLUDEBEGIN"resource."END2 TEXTINCLUDEBEGIN"#include ""afxres.h""\r"END3 TEXTINCLUDEBEGIN"\r"END#endif // APSTUDIO_INVOKED#endif // English (U.K.) resources/////////////////////////////////////////////////////////////////////////////#ifndef APSTUDIO_INVOKED///////////////////////////////////////////////////////////////////////////////// Generated from the TEXTINCLUDE 3 resource.///////////////////////////////////////////////////////////////////////////////#endif // not APSTUDIO_INVOKED
  •  If necessary add the appropriate #include directives for resource definition header files (windows.h, commctrl.h, …) to the beginning of the .rc file
  • Compile it running the RC program from the command prompt opened by Plaform Builder. Remember the /r switch (emit .res file)
  • You would probably use even the /i switch (additional include path, typically %_WINCEROOT%\PUBLIC\COMMON\SDK\INC)
Advertisements
This entry was posted in Windows Embedded CE and tagged . Bookmark the permalink.

2 Responses to How to Edit Windows CE Binary Resource Files

  1. Pingback: About Resource Hacker « ANDREAS TOBERICK Blog

    • lcalligaris says:

      I’ve used that program in the past and I found it useful although sometimes the modifications were not consistent (it was a lot of time ago, I do not remember the details, sorry)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s