Setting IE's page setup from application

561 Views Asked by At

I found the IE's page setup settings stored at:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup

But the IE's left margin value set within IE is 0.5 but the key value is 0.019690.

Which format does IE store those values and how can I convert to it?

My current code look like this:

   void setPageSetup()
        {
            const string SubkeyPath = @"Software\Microsoft\Internet Explorer\PageSetup";

            using (var key = Registry.CurrentUser.OpenSubKey(SubkeyPath, true))
            {
                    string regName = "margin_left";
                    double myRegValue = 0.5;
                    string regValue = Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(myRegValue.ToString() + "\0")));
                    key.SetValue(regName, regValue);
            }
        }

NOTE: Yes, the user knows I going to chage this. I plan to restore it later (getting the current IE's page margin values, set new ones, then before application exit set the initial values back).

0

There are 0 best solutions below