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

  • Home
  • SEARCH
  • 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 8187741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:39:51+00:00 2026-06-07T02:39:51+00:00

I have application which reads key in registry entry. Its working good on Multi-Byte

  • 0

I have application which reads key in registry entry.

Its working good on Multi-Byte Character Set

But On Unicode character set it cannot open key

This is my code:

HKEY hkey = 0;
    char buf[255] = {0};
    DWORD dwType = 0;
    DWORD dwBufSize = sizeof(buf);
    const char* subkey_x64 = "SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\UCP";
    const char* subkey_x86 = "SOWTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\UCP";

    if (RegOpenKey(HKEY_LOCAL_MACHINE, (LPCWSTR)subkey_x64, &hkey) == ERROR_SUCCESS)
    {
        dwType = REG_SZ;
        if (RegQueryValueEx(hkey, (LPCWSTR)"DisplayIcon", 0, &dwType, (BYTE*)buf, &dwBufSize) == ERROR_SUCCESS)
        {
            cout << "Key Value IS: " << buf << endl;
        }
        else
        {
            cout << "Cannot get key value..." << endl << endl;
        }
    }
    else
    {
        cout << "Cannot open key\n" << endl << endl;
        RegCloseKey(HKEY_PERFORMANCE_DATA);
    }

Does anybody have an idea why it cannot open key?

(LPCWSTR) is not good approach?

Im using visual studio 2010

  • 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-06-07T02:39:52+00:00Added an answer on June 7, 2026 at 2:39 am

    const char* is not an Unicode string. Change to const wchar_t* and you won’t need a cast.

    With the cast you say the compiler to interpret that address as a pointer to an Unicode string but it’s not.

    Moreover when you declare an Unicode string literal you should use L prefix: L"DisplayIcon" (again no need for a cast). If your code may run both on Unicode and multi-byte you may use the TEXT() macro to do the trick for you (or its short version _T()): _T("DisplayIcon").

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little app which reads registry key string values. It works well
I have a silverlight application which reads data from a db and displays them
I have an application which reads a license file when it starts up. My
I have a little C# console application that reads a key and checks to
We have an application which stores its data in SQL Server. Each table has
I have a console application which has its own App.config. I need to change
I have a java application which needs to read and write files to HDFS.
We are developing an application which is read heavy and could possibly have millions
I have read from some article that say's Apple doesn't approve the application which
I have application which uses Sherlock ActionBar package. The application uses platform-specific behavior for

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.