title: Write dword value in Registry with Delphi
body: <p>My program has a TWebBrowser where the user can open all kinds of local documents. To avoid that for example a Word document is opened in Word instead of in the TWebBrowser (that is to say, in Internet Explorer), I successfully use a fix in the Registry, by executing a .reg file with this instruction:</p>
  
  <blockquote>
    <p>[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Word.Document.12]
    "BrowserFlags"=dword:80000024</p>
  </blockquote>
  
  <p>I am trying to introduce that instruction in the Delphi program itself, with this code:</p>
  
  <pre><code>procedure RegOpenExplorer;
  var
    reg: TRegistry;
  begin
    reg:= TRegistry.Create;
    try
      reg.RootKey:=HKEY_LOCAL_MACHINE;
      reg.OpenKey('SOFTWARE\Classes\Word.Document.12\', true);
      reg.WriteInteger('BrowserFlags',80000024);
      reg.CloseKey;
    finally
      reg.Free;
    end;
  end;
  </code></pre>
  
  <p>It does not work, actually the effect is undoing the fix.</p>
  
  <p>When successfully manipulated with the .reg file (or manually), the Registry key looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/F7zcS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F7zcS.png" alt="good key"></a></p>
  
  <p>But with my unsuccessful Delphi Code, the key becomes as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/1X9nQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1X9nQ.png" alt="bad key"></a></p>
  
  <p>The difference is the number in brackets, but that is something that the Registry introduces automatically by itself.</p>