Path: csiph.com!feeder.erje.net!1.eu.feeder.erje.net!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Wolfgang Riedmann" Newsgroups: comp.lang.clipper.visual-objects Subject: Re: Registry HKLM not accessible as expected Date: Wed, 7 Mar 2018 16:14:51 +0100 Lines: 66 Message-ID: References: <12vv9dh4plhm771833rcs5f9bfik5mfm7v@4ax.com> X-Trace: individual.net zUK6N/5ySSJ6foJI67SsXQ/kod8SK2w3i8szmxtyvY6J6QqvI= Cancel-Lock: sha1:5D3L0CD1CZrimLNADCAWmHUgO8o= User-Agent: XanaNews/1.18.1.6 Xref: csiph.com comp.lang.clipper.visual-objects:11466 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. --