Using UpdateResource() to add a resource

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've seen plenty of examples of updating a resource using UpdateResource().
Has anyone actually used it to add a new resource? For example, a menu
resource. If so, how is it done? I'm not quit sure how to present the raw
data.
 
Klaatu said:
I've seen plenty of examples of updating a resource using
UpdateResource().
Has anyone actually used it to add a new resource? For example, a menu
resource. If so, how is it done? I'm not quit sure how to present the
raw
data.

I think you are about to step into one of the darker corners of Win32
programming. I don't want to sound like I am dissuading if you have decided
you must go this way ... but do you know that you can build menus at
runtime? It may be a better option.

If you want to go this route, take a look at this link:

http://msdn.microsoft.com/library/d...terface/Resources/IntroductiontoResources.asp

It contains this quip in the paragraph on the MENUHEADER structure:

<quote>
The MENUHEADER structure contains version information for the menu resource.
The structure definition provided here is for explanation only; it is not
present in any standard header file.
</quote>

The help entry for the UpdateResource() function points out that you must
pass a pointer to the "raw data" to be used in the update so I think that
you will first have to dump an existing menu resource, determine its binary
format by looking at the header and your resource script, get an idea of the
format, do the update, test and repeat until it works. :-(

Regards,
Will
 
William:

Thanks for the advice. Yes, I'm aware that I can create the menus
dynamically. Our current menu structure does just that. The real reason I
need to update resources is for translation issues. Since we don't have menu
resources, and our menu text comes from a string table, I have to provide
them for our language translators. Giving them menu resources provides
context and organization when they use a tool like visual localize.
 
Thanks for the advice. Yes, I'm aware that I can create the menus
dynamically. Our current menu structure does just that. The real reason I
need to update resources is for translation issues. Since we don't have menu
resources, and our menu text comes from a string table, I have to provide
them for our language translators. Giving them menu resources provides
context and organization when they use a tool like visual localize.
Why not give the .rc file?
Plus, any localization company worth the name is able to deal with
resources in executables/dlls without you writing any extra tools.
 
Nice idea, but, our menu resources don't live in the .rc file. They are
built dynamically from strings in the stringtable and an external function
table.
 
Although I did eventually work through the binary layout of the resources in
the dll, I decided to abandon this approach in favor of writing out an XML
file that contains the menu structure. This resolved my problem since the
translator tool will import xml files.
 
Nice idea, but, our menu resources don't live in the .rc file. They are
built dynamically from strings in the stringtable and an external function
table.
Then you do not need UpdateResource. Just read it from the external file,
build it, and use it.
UpdateResource is to update the menu resource in the executable file.
 
Back
Top