[DUG] registry caching?
Ross Levis
ross at stationplaylist.com
Fri Aug 28 15:26:52 NZST 2009
I do mean elevated. I do all HKLM registry changes in a separate little app
which has a manifest which specifies that it requires elevated administrator
privileges. Not the official way to do things but it works. It will ask
for the UAC prompt if I run it manually.
But since the installer is elevated and it loads the app after installation,
it also gets the elevated rights by default.
So that's not the problem. I am looking at the registry using regedit.
During installation I can see the HKLM key appear in regedit. My app then
loads, and I see the registry key deleted by my app. It is definitely gone.
My app then loads my little helper app and the main app is terminated. No
matter how long the helper app sleeps before loading the main app again, the
registry setting is still taking effect.
Vista doesn't look in virtualized areas for the AppCompatFlags, so it must
be some sort of caching. What is strange is if I disable the main app from
loading the helper app, so my main app just terminates and doesn't get
reloaded, and I then manually load my app from the installed icon, it works
correctly. I don't think virtualization would explain that either.
I'm guessing it would work if I set the Windows Task Scheduler to load my
app in 5 seconds, but that seems a lot of work.
The only logical thing I can think of is there must be some information
being transferred when loading one program from another. Certainly elevated
privileges is one thing that is transferred in this situation.
Perhaps another way around it is to load both the helper app and main app
from the installer so they are loaded without any obvious link to each
other. The helper would then need to monitor the main app to see when it is
terminated, before restarting it. Could be worth a try when I get time.
Cheers,
Ross.
-----Original Message-----
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz] On
Behalf Of Conor Boyd
Sent: Friday, 28 August 2009 2:21 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] registry caching?
I've only recently had the "pleasure" of really getting to grips with
UAC, etc, so if I'm telling you stuff you already know, forgive me.
It does sound like this is a UAC or elevation issue.
When you say "raised privileges", do you mean "elevated"? You app
either runs elevated or it doesn't. Installers by default run elevated,
hence the UAC prompt when you start an installer.
If your installer writes to HKLM for example, it will be writing to the
"real" HKLM as opposed to a virtualised one.
I'm still unclear as to whether your app will be running elevated. If
it's not running elevated and e.g. tries to write to HKLM, it will be
writing to a virtualised copy of the registry. If it writes it's own
value to it's virtualised copy of the registry, then you can change the
"real" HKLM value to your hearts content, but your app will never see
those changes, since it will only see it's virtualised copy.
Like I said, this still smells like a registry virtualisation issue to
me.
However, if it's not HKLM keys (or other UAC-restricted territory such
as Program Files) we're talking about anyway, then I'm a bit stumped,
sorry. ;-)
C.
-----Original Message-----
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Ross Levis
Sorry, I should have mentioned it is Vista, but it'll be the same issue
with Win7. It's not a virtualization issue. This is all done with
raised privileges during and immediately after installation.
It seems to be caching the compatibility setting somehow. Or perhaps
the helper app is inheriting the setting and then inheriting it back to
the main app when it restarts it. It would appear a very stupid thing
for Windows to do if that is the case, but I'll test it to be sure.
-----Original Message-----
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
On Behalf Of Conor Boyd
Which OS?
If it's Vista (or Win 7), and your registry key is under e.g. HKLM, are
you running into registry virtualization issues?
-----Original Message-----
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz]
I hope someone can help.
I have an app where the installer sets an XP compatibility mode registry
entry during installation. Don't ask why but it is generally required.
As the app loads after installation, it checks some hardware
requirements to see if XP compatibility mode needs to be switched off.
If so, the registry entry is deleted and the program then needs to be
restarted, which I want to do automatically.
I have a helper app which I load just before terminating the main app.
The helper app then reloads the main app after a 2 second sleep.
However, the result is that the program is still loading in
compatibility mode even though the registry entry is deleted well before
it loads.
I have LazyWrite disabled on the registry change, so it is instantly
updated. I tried a massive 15 second sleep in the helper app, so the
main app is closed for 15 seconds before reloading, yet it still loads
as if the registry entry is still there.
If I terminate the app and load it manually, then it's always correct!
I don't understand this. Why would loading the app manually be any
different to loading it from another app?
I'm using CreateProcess with CREATE_NEW_PROCESS_GROUP to load the helper
app and to load the main app again. I tried ShellExecute with no
difference.
Is there some way to make this work automatically?
The only method I can adopt at this stage is to popup a message to ask
the user to load the program manually, which is not user friendly.
Many thanks,
Ross.
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
unsubscribe
More information about the Delphi
mailing list