Hacking Win7 Calculator–Adding Custom Unit Conversion

Windows 7 Calculator has added this nice little unit converters and templates, but I thought it would be cool to be able to customize your own ones.

Please note: this is a hack, not a proper solution. This is purely for educational purposes, modifying Windows binaries is typically a violation of the license agreement…and updates could potentially break this solution as well.

To start I backed up calc and related MUI files into a separate folder for working on. In this case I just used command xcopy C:\windows\system32\calc.* /s


As English is the only user interface language installed on this machine I only got the en-US MUI file. The MUI is basically a Windows Resource DLL that will contain language specific strings, images, dialog boxes, menus etc of an application.

We need something to edit the resources in the MUI file. For this I used the old class tool Resource Hacker http://www.angusj.com/resourcehacker/ To edit 64-bit resource files ensure you download the 64-bit version.

Please note this tool is no longer maintained, but it was the only freely available tool I tried that could let me correctly extract the XML resource and re-import it. If you know of others that work let me know.

With calc.exe.mui opened in Resource Hacker under the “23” (HTML) tree in Resource Hacker I saved the two resources IDS_TEMPLATE_XML and IDS_TEMPLATE_SCHEMA as “binary” files with an XML extension:


This gave me two XML files to edit


The IDS_TEMPLATE_XML resource contains the rules for the various templates


So let’s start with basics…I want to add a new Length conversion…While there are a lot of choices already


…I had read about Noah’s Ark and it was measured in Cubits and I wanted to convert it to metres. Now the size of a cubit is debated but the world almanac defines it as 17.5 inches.

First I needed to add the word “Cubits” to the String Table in Resource Hacker. I had to use a Resource ID number that was not already being used. After adding I hit “Compile Script”


I then added the display code into the XML. Again I had to ensure “cu” was not used anywhere else.



Then selected


(Note: TEMPALTE is misspelt on purpose, this is because it is misspelt in Windows resource file)

Unfortunately now calc.exe doesn’t launch…launching via WinDbg we see the failure is at


Now why is this? Examining our XML file we find the reason

-> Although the XML file specifies UTF-8 encoding, within the MUI file it is actually encoded in UNICODE (UTF-16) we can see this from the header of the file:


However when Visual Studio had saved the file…


So I opened the file in Notepad and saved in Unicode format. (Yes Visual Studio can save in Unicode format, but it will switch the utf-8 in XML header to utf-16 and we don’t want that)



I then re-imported the XML file via Resource hacker as demonstrated previously. Cubits are available as a conversion option but not yet functional.image

This is because we haven’t added our “To” formulas yet. So back to the XML…

Looking through the various “Length” formulas I found that Centimetres seemed to be the gold standard:



So I need a conversion of my inches to cm


Ok so I needed to multiply by 43.815…

So I added the formulas within the <unitFormulas hintBaseUnit=”cm”> section of the XML file. We simply add a “to” and “from” conversion ration. The “to” will be * whatever the value of our unit is in cm. The “from” will be / by whatever our unit is in cm.

          <formula name=cuTocm toUnit=cm fromUnit=cu>


              <unit unitName=cu></unit>

              <constantString formulaConst=* 43.815/>



          <formula name=cmTocu toUnit=cu fromUnit=cm>


              <unit unitName=cm></unit>

              <constantString formulaConst=/ 43.815/>




(Note: Now that I originally saved the file as unicode, Visual Studio will save it in unicode format without switching the utf-8 to utf-16)

OK and so now my conversion is working…


So with Noah’s ark recorded as 300 cubits long…so I now have it in metres


OK that was pretty simple. But what about customized Worksheets like the mortgage calculator? Creating custom worksheets to follow in next blog post. Any special requests?

About chentiangemalc

specializes in end-user computing technologies. disclaimer 1) use at your own risk. test any solution in your environment. if you do not understand the impact/consequences of what you're doing please stop, and ask advice from somebody who does. 2) views are my own at the time of posting and do not necessarily represent my current view or the view of my employer and family members/relatives. 3) over the years Microsoft/Citrix/VMWare have given me a few free shirts, pens, paper notebooks/etc. despite these gifts i will try to remain unbiased.
This entry was posted in Windows 7 and tagged . Bookmark the permalink.

4 Responses to Hacking Win7 Calculator–Adding Custom Unit Conversion

  1. Mike Jackson says:

    Any luck on creating a tutorial on adding custom worksheets/templates to the new windows 7 calculator?

  2. bremenpl says:

    Hi there,
    I am having problem using your solution. I am trying to add the “Mils” to the Lengh units. I do everything like you, but even though I cant see the added mils unit in units when I open the calc. I am editing the .xml file using notepad++. I would aprichiate any help really.

  3. aj says:

    chapeau bas :-)
    can you help me to set a unit converter with my default measurement units. as an example there is a length angstrom but i would like to have – let say – an inch. how can it be done?

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