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 4007232
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:36:30+00:00 2026-05-20T08:36:30+00:00

Can I Read Windows Registry From Windows Service in VC++ ? I have written

  • 0

Can I Read Windows Registry From Windows Service in VC++ ?

I have written code to read from Registry in MFC Application.It works fine but the same code does not work in Windows Service project.

My code looks like this:

TCHAR     szPasswordDecrypted[32] = _T("");
TCHAR*    szEncryptPwd = NULL ;

HKEY     hKey = NULL;
TCHAR    achKey[MAX_KEY_LENGTH];   // buffer for subkey name
DWORD    cbName;                   // size of name string 
TCHAR    achClass[MAX_PATH] = TEXT("");  // buffer for class name 
DWORD    cchClassName = MAX_PATH;  // size of class string 
DWORD    cSubKeys=0;               // number of subkeys 
DWORD    cbMaxSubKey;              // longest subkey size 
DWORD    cchMaxClass;              // longest class string 
DWORD    cValues;              // number of values for key 
DWORD    cchMaxValue;          // longest value name 
DWORD    cbMaxValueData;       // longest value data 
DWORD    cbSecurityDescriptor; // size of security descriptor 
FILETIME ftLastWriteTime;      // last write time


DWORD i, retCode; 

long lg = RegOpenKeyEx( HKEY_CURRENT_USER,
    TEXT("SOFTWARE\\NetworkDriveSolution"),
    0,
    KEY_READ,
    &hKey
    );

// Get the class name and the value count. 
retCode = RegQueryInfoKey(
    hKey,                    // key handle 
    achClass,                // buffer for class name 
    &cchClassName,           // size of class string 
    NULL,                    // reserved 
    &cSubKeys,               // number of subkeys 
    &cbMaxSubKey,            // longest subkey size 
    &cchMaxClass,            // longest class string 
    &cValues,                // number of values for this key 
    &cchMaxValue,            // longest value name 
    &cbMaxValueData,         // longest value data 
    &cbSecurityDescriptor,   // security descriptor 
    &ftLastWriteTime);       // last write time 
  • 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-20T08:36:30+00:00Added an answer on May 20, 2026 at 8:36 am

    HKEY_CURRENT_USER refers to the user the process is running as. Your service will likely run as LocalSystem, not as you. Best bet is to store information under HKEY_LOCAL_MACHINE.

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

Sidebar

Related Questions

I can read list of installed applications from registry: @SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall and on Vista and
I'm trying to read values from the registry but somehow I seem to be
I have a program that works fine on VS2008 and Vista , but I'm
I have a windows application which installs a Chrome extension via the windows registry.
I'm trying to read data from the registry @ SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\ The return value I
I am developing a WPF application where i can read some properties from the
I read Windows Azure Toolkit for Android to understand how I can connect Android
I have some problem with my open new window popup which it can read
I can read unmanaged memory in C# using UnmanagedMemoryStream, but how can I do
I can read XLS file with this code : string path =@c:\r\1.xlsx; OleDbConnection MyConnection

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.