Article View: borland.public.cppbuilder.nativeapi
Article #1983Re: System service accessing HKEY_CURRENT_USER
From: Remy Lebeau (TeamB)
Date: Wed, 23 May 2007 17:19
Date: Wed, 23 May 2007 17:19
28 lines
1723 bytes
1723 bytes
"Jeff" <Jeff@nospam.com> wrote in message
news:46545b9a@newsgroups.borland.com...
> I've got a system service that needs to access a user's registry
value.
In order to do that, the service must first log in to the user's
account as well as load that user's Registry hive if it ihas not
already been loaded by the OS earlier.
> I've written a function to impersonate the user and then access the
> registry (HKEY_CURRENT_USER), but it always get back a
> false value (see code below).
You did not load the user's Registry hive. You need to call
RegLoadKey() after impersonating the user. Have a look at the
following article for more details:
Why Do Certain Win32 Technologies Misbehave in Windows NT
Services?
http://www.microsoft.com/msj/0398/service2.aspx
In particular, look at the "Registry Hives" section at the very end of
the article.
Gambit
Technical Details
Message-ID:
<46547951@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<46545b9a@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,896f59c6a0f395d7 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <46545b9a@newsgroups.borland.com> Subject: Re: System service accessing HKEY_CURRENT_USER Date: Wed, 23 May 2007 10:19:22 -0700 Lines: 30 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 75.82.60.244 Message-ID: <46547951@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1179941201 75.82.60.244 (23 May 2007 10:26:41 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail