title: Write to registry based on a condition
body: <p>I want to write to registry based on OS. I have OS detection function in place and found out that you can put a check function in registry section, so tried following:</p>
  
  <pre><code>Root: HKLM; SubKey: Software\Microsoft\Windows; ValueType: dword; ValueName: Test; ValueData: 1; Flags: createvalueifdoesntexist; Check: IsWindows7
  </code></pre>
  
  <p>But it didn't work, means that when I installed on Win7 and WinXP, it wrote the value to the  registry in both cases.</p>
  
  <p>Here is the code to detect OS:</p>
  
  <pre><code>function IsWindows7(): Boolean;
  var
    Version: TWindowsVersion;
  begin
    GetWindowsVersionEx(Version);
  
    // Windows 7 version is 6.1 (workstation)
    if (Version.Major = 6)  and
       (Version.Minor = 1) and
       (Version.ProductType = VER_NT_WORKSTATION)
    then
      Result := True
    else
      Result := False;
  end;
  </code></pre>
  
  <p>Any ideas/suggestions?</p>