Search code examples
cwinapiassemblydata-structuresmodern-ui

winapi how to change a windows resource language programatically


trying to change resource languages into an exe/dll file programatically, I've tried to do that with UpdateResource but it doesn't work since the language per item is not part of the resource template, it seems to be in a structure caller RESOURCEHEADER which is located at the beginning of each resource type...

Thus accessing to this part seems to be a bit complicated, no API to do that.

The only thing left would be to reverse engineer the structure and update the binary directly, but I prefer asking before.


Solution

  • I can't think why you'd want to do this, but anyway...

    Call

    UpdateResource(hUpdate, lpType, lpName, wOldLanguage,  0, 0);
    

    to delete the existing language resource and

    UpdateResource(hUpdate, lpType, lpName, wNewLanguage, lpData, cbData);
    

    to write a new resource with the new language identifier, where lpData and cbData refer to a copy of the existing resource data.

    Note that it gets a lot more complicated if you are using MUI. The UpdateResource docs have the details.