For Programmers: Free Programming Magazines  


Home > Archive > VC Language > June 2005 > Is there a way for Windows Service to Read/Write HKCU Reg key ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Is there a way for Windows Service to Read/Write HKCU Reg key ?
Polaris

2005-06-10, 4:04 am

Hi:

I'm writing a Windows Service program which needs to read/write the
HKEY_CURRENT_USER registry key for the current logged on user. I know that
for a Windows service does not have concept of HKCU since it is always
running in SYSTEM's context. But is there a way (trick?) for a service to
access the HKCU registry key?

Thanks In Advance !
Polaris


lallous

2005-06-10, 8:59 am

Hello

Try, from a user application (the one that is logged on, or the current
user), to send the services the user's SID.

Then access the HKCU through HKEY_USERS\users_sid\............

Hope that helps,
Elias
"Polaris" <etpolaris@hotmail.com> wrote in message
news:OPbH9BYbFHA.3132@TK2MSFTNGP09.phx.gbl...
> Hi:
>
> I'm writing a Windows Service program which needs to read/write the
> HKEY_CURRENT_USER registry key for the current logged on user. I know that
> for a Windows service does not have concept of HKCU since it is always
> running in SYSTEM's context. But is there a way (trick?) for a service to
> access the HKCU registry key?
>
> Thanks In Advance !
> Polaris
>



andré m.a

2005-06-10, 8:59 pm


"Polaris" <etpolaris@hotmail.com> wrote in message
news:OPbH9BYbFHA.3132@TK2MSFTNGP09.phx.gbl...
> Hi:
>
> I'm writing a Windows Service program which needs to read/write the
> HKEY_CURRENT_USER registry key for the current logged on user. I know that
> for a Windows service does not have concept of HKCU since it is always
> running in SYSTEM's context. But is there a way (trick?) for a service to
> access the HKCU registry key?
>
> Thanks In Advance !
> Polaris
>


I think you could user GetUserName(...) for this.


William DePalo [MVP VC++]

2005-06-10, 8:59 pm

"andré m.a" <a.m.a@videotron.ca> wrote in message
news:EJmqe.49089$jO.747873@weber.videotron.net...
>
> I think you could user GetUserName(...) for this.


No. The function returns the user name associated with the calling thread.
The OP's post states that his service is running as "SYSTEM" (actually
LocalSystem).

Regards,
Will


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com