Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #11463 > unrolled thread
| Started by | D.J.W. van Kooten <vankooten@removethis.ic2.com> |
|---|---|
| First post | 2018-03-07 14:58 +0100 |
| Last post | 2018-03-07 12:47 -0500 |
| Articles | 8 — 4 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
Registry HKLM not accessible as expected D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-03-07 14:58 +0100
Re: Registry HKLM not accessible as expected "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-03-07 15:26 +0100
Re: Registry HKLM not accessible as expected D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-03-07 15:54 +0100
Re: Registry HKLM not accessible as expected "Wolfgang Riedmann" <wriedmann@gmail.com> - 2018-03-07 16:14 +0100
Re: Registry HKLM not accessible as expected D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-03-07 23:41 +0100
Re: Registry HKLM not accessible as expected Mathias <mathias.hakansson@consultec.se> - 2018-03-08 02:13 -0800
Re: Registry HKLM not accessible as expected D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2018-03-08 12:07 +0100
Re: Registry HKLM not accessible as expected "Jamal" <noooospam@example.com> - 2018-03-07 12:47 -0500
| From | D.J.W. van Kooten <vankooten@removethis.ic2.com> |
|---|---|
| Date | 2018-03-07 14:58 +0100 |
| Subject | Registry HKLM not accessible as expected |
| Message-ID | <nlrv9d17h303ogeeokte9a8r619spvndak@4ax.com> |
We used to store registry values to HKCU which was in many cases not
ideal. I changed this to HKLM all over my program and found no entries
there (even on my own Pc) ; instead the values are written in 2
locations
Computer\HKEY_USERS\S-1-5-21-3025325910-2195600122-3119758833-1001_Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\(etc)
where I wanted HKLM\SOFTWARE\(etc).
I have 2 questions:
1 How can I prevent that the system uses "Virtiual Store"? See the
function as we use below.
2 I know that WOW6432Node is used for 32 bits apps in a 64 bit
environment. DO I need to check on this on writing to the registry or
will Windows automatically take care of that?
And can it differ depending on someone's pc in a network?
Basically this is the code we use:
li_Error := RegCreateKeyEx( ;
SELF:hKeyP, ; // hKeyP
AS PTR
String2Psz( s_Full_SubKey ), ; // lpSubKey
AS PSZ
0, ; // Reserved
AS DWORD
String2Psz( SELF:s_Class ), ; // lpClass
AS PSZ
REG_OPTION_NON_VOLATILE, ; //
dwOptions AS DWORD
KEY_SET_VALUE + KEY_CREATE_SUB_KEY, ; //
samDesired AS DWORD
0, ; //
lpSecurityAttributes AS _winSECURITY_ATTRIBUTES
@dw_KeyHandle, ; //
phkResult AS PTR
@dw_Disposition ; //
lpdwDisposition AS DWORD PTR
) // AS LONG
PASCAL:ADVAPI32.RegCreateKeyExA#130
Dick
[toc] | [next] | [standalone]
| From | "Wolfgang Riedmann" <wriedmann@gmail.com> |
|---|---|
| Date | 2018-03-07 15:26 +0100 |
| Message-ID | <fgab5cFn8qvU1@mid.individual.net> |
| In reply to | #11463 |
Hi Dick, HKLM is writable only with elevated rights. If you need to write machine-wide values without administrative rights, you need other ways, maybe a configuration file in the c:\ProgramData. If you need code to elevate rights: I can give you something (but in X#). Wolfgang D.J.W. van Kooten wrote: > We used to store registry values to HKCU which was in many cases not > ideal. I changed this to HKLM all over my program and found no entries > there (even on my own Pc) ; instead the values are written in 2 > locations > > Computer\HKEY_USERS\S-1-5-21-3025325910-2195600122-3119758833-1001_Cla > sses\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\(etc) > > where I wanted HKLM\SOFTWARE\(etc). > > I have 2 questions: > > 1 How can I prevent that the system uses "Virtiual Store"? See the > function as we use below. > > 2 I know that WOW6432Node is used for 32 bits apps in a 64 bit > environment. DO I need to check on this on writing to the registry or > will Windows automatically take care of that? > > And can it differ depending on someone's pc in a network? > > Basically this is the code we use: > > li_Error := RegCreateKeyEx( ; > SELF:hKeyP, ; // hKeyP > AS PTR > String2Psz( s_Full_SubKey ), ; // lpSubKey > AS PSZ > 0, ; // Reserved > AS DWORD > String2Psz( SELF:s_Class ), ; // lpClass > AS PSZ > REG_OPTION_NON_VOLATILE, ; // > dwOptions AS DWORD > KEY_SET_VALUE + KEY_CREATE_SUB_KEY, ; // > samDesired AS DWORD > 0, ; // > lpSecurityAttributes AS _winSECURITY_ATTRIBUTES > @dw_KeyHandle, ; // > phkResult AS PTR > @dw_Disposition ; // > lpdwDisposition AS DWORD PTR > ) // AS LONG > PASCAL:ADVAPI32.RegCreateKeyExA#130 > > > > Dick --
[toc] | [prev] | [next] | [standalone]
| From | D.J.W. van Kooten <vankooten@removethis.ic2.com> |
|---|---|
| Date | 2018-03-07 15:54 +0100 |
| Message-ID | <12vv9dh4plhm771833rcs5f9bfik5mfm7v@4ax.com> |
| In reply to | #11464 |
Replying on message of Wed, 7 Mar 2018 15:26:52 +0100 from Wolfgang Riedmann: Hello Wolfgang, >HKLM is writable only with elevated rights. > >If you need to write machine-wide values without administrative rights, >you need other ways, maybe a configuration file in the c:\ProgramData. > >If you need code to elevate rights: I can give you something (but in >X#). > Yes, that would be great. Can you mail me the code? The point is that direct registry access via Regedit is usually prohibited for many users while user files are not. So I prefer my prgram to store certain settings in a registry, and one from which I can find back the keys and which are the same for every user when they are on a (RD) server. I found indeed quite some postings on the internet with this problem. One of them saying: <sarcasm>Thank you microsoft, again, you know exactly what the program/user wants to do better than themselves.</sarcasam> >:( I can only agree with that. Dick
[toc] | [prev] | [next] | [standalone]
| From | "Wolfgang Riedmann" <wriedmann@gmail.com> |
|---|---|
| Date | 2018-03-07 16:14 +0100 |
| Message-ID | <fgadvcFntb3U1@mid.individual.net> |
| In reply to | #11465 |
Hi Dick,
> > HKLM is writable only with elevated rights.
> >
> > If you need to write machine-wide values without administrative
> > rights, you need other ways, maybe a configuration file in the
> > c:\ProgramData.
> >
> > If you need code to elevate rights: I can give you something (but in
> > X#).
> >
>
> Yes, that would be great. Can you mail me the code? The point is that
> direct registry access via Regedit is usually prohibited for many
> users while user files are not. So I prefer my prgram to store certain
> settings in a registry, and one from which I can find back the keys
> and which are the same for every user when they are on a (RD) server.
if your user cannot have elevated rights, then you will not be able to
write these values.
You have two possibilities: you can declare that your program needs
administrative rights via a application manifest (and that works even
with a VO program), or you can check if your program is already running
with elevated rights:
static method IsRunningElevated() as logic
local lReturn as logic
if WindowsPrincipal{ WindowsIdentity.GetCurrent() }:IsInRole(
WindowsBuiltInRole.Administrator )
lReturn := true
else
lReturn := false
endif
return lReturn
and if not, restart it with elevated rights:
cPrgFileName :=
System.Reflection.Assembly.GetExecutingAssembly().Location
oStartInfo := ProcessStartInfo{}
oStartInfo:FileName := cPrgFileName
oStartInfo:UseShellExecute := true
oStartInfo:Verb := "runas"
Process.Start( oStartInfo )
> I found indeed quite some postings on the internet with this problem.
> I can only agree with that.
Unfortunately, I cannot agree with that.
IMHO it is very important that a process that is not using elevated
rights CANNOT write to HKLM.
Tis is very important for security purposes, and is one of the
precautions that made Windows 7 and later more secure than XP and
previous versions.
Wolfgang
P.S. don't try to work against the system - work with it.
--
[toc] | [prev] | [next] | [standalone]
| From | D.J.W. van Kooten <vankooten@removethis.ic2.com> |
|---|---|
| Date | 2018-03-07 23:41 +0100 |
| Message-ID | <v0q0add08b6on139eqak1kbvv5i963ciqo@4ax.com> |
| In reply to | #11466 |
Replying on message of Wed, 7 Mar 2018 16:14:51 +0100 from Wolfgang Riedmann: Hello Wolfgang, >You have two possibilities: you can declare that your program needs >administrative rights via a application manifest (and that works even >with a VO program), or you can check if your program is already running >with elevated rights: Thanks for the code. If I understand you correctly I will have to use a .Net program to get this working so I decided to revert my changes and contine with the less optimal method of HKCU. The code below can come in handy for future full X# programs. I am not very enthousiastic to make changes in manifests as these can easily lead to exe's that won't start. >IMHO it is very important that a process that is not using elevated >rights CANNOT write to HKLM. >Tis is very important for security purposes, and is one of the >precautions that made Windows 7 and later more secure than XP and >previous versions. > >P.S. don't try to work against the system - work with it. The registry would be a good place to store program values as you can deny direct access to it from RegEdit. If it were well designed, it should be possble to register somehow that your program can (as only program) use HKLM\Software\MyProduct. But it isn't. What you call "working with the system" basically means : "In order to get something working, you have to go through a time consuming bag of tricks (after which you can still use the registry) and so can anyone else, even virus writers, if they apply the same tricks. Or you give up and go to a less ideal solution (ini files or HKCU)." It's like throwing a pile of burning tires on a highway but after some research you acn still reach the other site of the burning pile by taking a detour. Like with most Microsoft "solutions". Dick
[toc] | [prev] | [next] | [standalone]
| From | Mathias <mathias.hakansson@consultec.se> |
|---|---|
| Date | 2018-03-08 02:13 -0800 |
| Message-ID | <5d4136f7-edfd-413b-8885-da8866c5e6c9@googlegroups.com> |
| In reply to | #11468 |
Hi, You don't need a -net program to elevate your rights. The easiest way to do this regardless of Environment is to have a separate exe that does the registry writing. This exe could take the key and the value as parameters and should demand elevated rights with a manifest. You can start this exe from your main program with the proper parameters. When you start this exe the UAC dialog will be displayed and the user has to enter the credentials for the local administrator account, or if already logged in as a local administrator the user has to acknowledge the rights elevation. Since windows Vista certain areas of the registry and the file system is protected and the Virtual Store functionality provides compatibility for older applications. The virtual store is however per user. So information that were shared between users before may now have become personal. /MathiasH Den onsdag 7 mars 2018 kl. 23:41:45 UTC+1 skrev D.J.W. van Kooten: > Replying on message of Wed, 7 Mar 2018 16:14:51 +0100 from Wolfgang > Riedmann: > > > Hello Wolfgang, > > >You have two possibilities: you can declare that your program needs > >administrative rights via a application manifest (and that works even > >with a VO program), or you can check if your program is already running > >with elevated rights: > > > Thanks for the code. If I understand you correctly I will have to use > a .Net program to get this working so I decided to revert my changes > and contine with the less optimal method of HKCU. The code below can > come in handy for future full X# programs. I am not very enthousiastic > to make changes in manifests as these can easily lead to exe's that > won't start. > > >IMHO it is very important that a process that is not using elevated > >rights CANNOT write to HKLM. > >Tis is very important for security purposes, and is one of the > >precautions that made Windows 7 and later more secure than XP and > >previous versions. > > > >P.S. don't try to work against the system - work with it. > > The registry would be a good place to store program values as you can > deny direct access to it from RegEdit. If it were well designed, it > should be possble to register somehow that your program can (as only > program) use HKLM\Software\MyProduct. But it isn't. What you call > "working with the system" basically means : > > "In order to get something working, you have to go through a time > consuming bag of tricks (after which you can still use the registry) > and so can anyone else, even virus writers, if they apply the same > tricks. Or you give up and go to a less ideal solution (ini files or > HKCU)." > > It's like throwing a pile of burning tires on a highway but after some > research you acn still reach the other site of the burning pile by > taking a detour. Like with most Microsoft "solutions". > > Dick
[toc] | [prev] | [next] | [standalone]
| From | D.J.W. van Kooten <vankooten@removethis.ic2.com> |
|---|---|
| Date | 2018-03-08 12:07 +0100 |
| Message-ID | <b762adpm171dc8rufejtrg31nfng70lu4v@4ax.com> |
| In reply to | #11470 |
Replying on message of Thu, 8 Mar 2018 02:13:18 -0800 (PST) from Mathias: Hello Mathias > >Since windows Vista certain areas of the registry and the file system is protected and the Virtual Store functionality provides compatibility for older applications. The virtual store is however per user. So information that were shared between users before may now have become personal. That's why I reverted my changes back to HKCU. A virtual Store 'per user' = HKCU. For a moment I thought I could change something to be more useful, but that is not how Windows is designed. Dick
[toc] | [prev] | [next] | [standalone]
| From | "Jamal" <noooospam@example.com> |
|---|---|
| Date | 2018-03-07 12:47 -0500 |
| Message-ID | <p7p8jh$qhf$1@news.albasani.net> |
| In reply to | #11463 |
Dick,
It is probably easier to use an INI file to save certain values instead of
fighting the Windows registry.
Jamal
"D.J.W. van Kooten" wrote in message
news:nlrv9d17h303ogeeokte9a8r619spvndak@4ax.com...
We used to store registry values to HKCU which was in many cases not
ideal. I changed this to HKLM all over my program and found no entries
there (even on my own Pc) ; instead the values are written in 2
locations
Computer\HKEY_USERS\S-1-5-21-3025325910-2195600122-3119758833-1001_Classes\VirtualStore\MACHINE\SOFTWARE\WOW6432Node\(etc)
where I wanted HKLM\SOFTWARE\(etc).
I have 2 questions:
1 How can I prevent that the system uses "Virtiual Store"? See the
function as we use below.
2 I know that WOW6432Node is used for 32 bits apps in a 64 bit
environment. DO I need to check on this on writing to the registry or
will Windows automatically take care of that?
And can it differ depending on someone's pc in a network?
Basically this is the code we use:
li_Error := RegCreateKeyEx( ;
SELF:hKeyP, ; // hKeyP
AS PTR
String2Psz( s_Full_SubKey ), ; // lpSubKey
AS PSZ
0, ; // Reserved
AS DWORD
String2Psz( SELF:s_Class ), ; // lpClass
AS PSZ
REG_OPTION_NON_VOLATILE, ; //
dwOptions AS DWORD
KEY_SET_VALUE + KEY_CREATE_SUB_KEY, ; //
samDesired AS DWORD
0, ; //
lpSecurityAttributes AS _winSECURITY_ATTRIBUTES
@dw_KeyHandle, ; //
phkResult AS PTR
@dw_Disposition ; //
lpdwDisposition AS DWORD PTR
) // AS LONG
PASCAL:ADVAPI32.RegCreateKeyExA#130
Dick
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web