Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 928273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:59:06+00:00 2026-05-15T19:59:06+00:00

I am trying to retrieve some values from the registry. Here is the full

  • 0

I am trying to retrieve some values from the registry.
Here is the full path:
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes]
“ThemeChangesMousePointers”=0x00000001 (1)

And here is my code:

HKEY hKey;
DWORD dwDisp = REG_DWORD;
DWORD dwType;
DWORD dwSize = sizeof(DWORD);
DWORD dwValue = 0;
DWORD dwReturn;
char buffer[255] = {0};
//char* buffer;
//DWORD buffer = 0;
DWORD dwBufSize = sizeof(buffer);

if( RegOpenKey(HKEY_LOCAL_MACHINE,
    _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes")
    ,&hKey) == ERROR_SUCCESS)
{
    dwType = REG_DWORD;
    if( RegQueryValueEx(hKey,_T("ThemeChangesMousePointers"),0, &dwType, (LPBYTE) buffer, &dwBufSize) == ERROR_SUCCESS)
    {
        printf("Key value is: %d \n", buffer);
        printf("GetLastError reports %d \n", GetLastError());
    }
    else
    {
        printf("Cannot query for key value \n");
    }
}

I have tried debugging and it seems like my buffer output variable is giving me a weird output:

Key value is: 2554292
Error is 0

Every time I run the code again, I get different values. How can I get the real value and not a different one?

EDIT: Post above has been edited to ask a different question.

Also, if this isn’t enough code, I can add more.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T19:59:06+00:00Added an answer on May 15, 2026 at 7:59 pm

    RegQueryValueEx does not call SetLastError, it returns it’s error code directly.

    Return Value

    If the function succeeds, the return value is ERROR_SUCCESS.
    If the function fails, the return value is a system error code.
    If the lpData buffer is too small to receive the data, the function returns ERROR_MORE_DATA.
    If the lpValueName registry value does not exist, the function returns ERROR_FILE_NOT_FOUND.

    EDIT IN RESPPONSE TO COMMENT:

    I initially answered your specific question, bit with regards to the code you posted, there are still several remaining problems:

    • You’re calling the deprecated method RegOpenKey rather than RegOpenKeyEx.
    • You’re trying to read an integer but you’re reading it as a char * string. This is the most likely cause of the problems you’re getting… the function’s returning an integer but you’re printing it as a string.
    • Your IF conditional is backwards
    HKEY hKey;
    DWORD dwDisp = REG_DWORD;
    DWORD dwSize = sizeof(DWORD);
    DWORD dwValue = 0;
    DWORD dwReturn;
    DWORD dwBufSize = sizeof(DWORD);
    
    if( RegOpenKeyExW(HKEY_LOCAL_MACHINE,
        L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes"
        ,0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
    {
        DWORD error = RegQueryValueExW(hKey,L"ThemeChangesMousePointers",0,0, reinterpret_cast<LPBYTE>(&dwReturn), &dwBufSize);
        if(error == ERROR_SUCCESS)
        {
            printf("Key value is: %d \n", dwReturn);
        }
        else
        {
            printf("Cannot query for key value; Error is: %d\n", error);
        }
    }
    RegCloseKey(hKey);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some issues trying to retrieve unique values from a DataSet in csharp,
I'm trying to retrieve some most occurring values from a SQLite table containing a
I am trying to save some values from my app using NSCoding. I'm able
I am trying to retrieve a set of values from database and assigned it
Here's what I'm trying to do: - Retrieve a Map of key-value pairs from
I'm trying to retrieve some data from a JSON response, but this doesn't seem
I am trying to use LINQ to retrieve some data from a dictionary. var
I am trying to retrieve multiple values from the session variable in which I
I have been have issues trying to retrieve the values from a treeMap that
I am trying to retrieve some rows from the database using simple SELECT statement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.