Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>GetRegistry()</code> returns a <code>char*</code>, so you are actually comparing <strong>pointers</strong> with <code>operator==</code>. You should use <code>strcmp()</code> to do raw C-like <code>char*</code> string comparisons, or better use a robust C++ string class, like <code>CString</code> or <code>std::[w]string</code>.</p> <p>Here is a possible rewrite of your function using ATL's <code>CString</code>:</p> <pre><code>#include &lt;atlbase.h&gt; #include &lt;atlstr.h&gt; CString GetRegistry(LPCTSTR pszValueName) { // Try open registry key HKEY hKey = NULL; LPCTSTR pszSubkey = _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\MCI Extensions"); if ( RegOpenKey(HKEY_LOCAL_MACHINE, pszSubkey, &amp;hKey) != ERROR_SUCCESS ) { // Error: // throw an exception or something... // // (In production code a custom C++ exception // derived from std::runtime_error could be used) AtlThrowLastWin32(); } // Buffer to store string read from registry TCHAR szValue[1024]; DWORD cbValueLength = sizeof(szValue); // Query string value if ( RegQueryValueEx( hKey, pszValueName, NULL, NULL, reinterpret_cast&lt;LPBYTE&gt;(&amp;szValue), &amp;cbValueLength) != ERROR_SUCCESS ) { // Error // throw an exception or something... AtlThrowLastWin32(); } // Create a CString from the value buffer return CString(szValue); } </code></pre> <p>And then you can call it like this:</p> <pre><code>if ( GetRegistry(_T("First")) == GetRegistry(_T("Second")) ) ... </code></pre> <p>Note that this code will compile in both ANSI/MBCS and Unicode builds (it's based on Win32 <code>TCHAR</code> model).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload