title: NSIS - check if registry key value exists
body: <p>I need to check, if a registry value exists. How can I do that?</p>
  
  <p>My first approach:</p>
  
  <pre><code>ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" "NUL:"
          ${IF} $0 == ""
                MESSAGEBOX MB_OK "NUL exists"
          ${ELSE}
                 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" "NUL:" ""
          ${ENDIF}
  </code></pre>
  
  <p>But this also works, when the value doesn’t exist. I guess, because "doesn’t exist" and empty string are handled the same way.</p>
  
  <p>With Registry.nsh I did it like this:</p>
  
  <pre><code>${registry::Read} "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports" "NUL:" $var1 $var2
  
          ${IF} $var2 == "REG_SZ"
  </code></pre>
  
  <p>But I get an error, because the Pop ${_STRING} in the registry.nsh doesn’t work.</p>
  
  <p>Help and suggestions welcome!</p>