Re: SystemRoot: XP vs VISTA
- From: Rob Kennedy <me3@xxxxxxxxxxx>
- Date: Thu, 08 Feb 2007 22:16:43 -0600
Tom de Neef wrote:
In a borrowed piece of code (for html help) I have
Reg.RootKey := HKEY_CLASSES_ROOT;
if Reg.OpenKeyReadOnly(hhPathRegKey)
then result := Reg.ReadString('');
Under XP this result in 'C:\WINDOWS\System32\hhctrl.ocx'
My application didn't open the help system under Vista because the same code then results in
'%SystemRoot%\System32\hhctrl.ocx'
By searching with regedit I've discovered that SystemRoot is defined in
'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion'
With StringReplace I now substitute the parameter.
That registry key is stored with reference to an environment variable. Use the ExpandEnvironmentStrings API function to replace the environment variable with its actual value. Don't dig around in the registry any more than you absolutely have to.
The registry has a data type for storing environment-variable-based values. When you read from those keys, the OS is supposed to fill in the actual value for you. Check (in regedit.exe) the type of the key you're reading. Is it Reg_Expand_Sz, or just Reg_Sz? This is to determine whether it's the OS that is using the wrong type, or Delphi that is ignoring that type. You can't fix the former, but you can address the latter.
--
Rob
.
- Follow-Ups:
- Re: SystemRoot: XP vs VISTA
- From: Tom de Neef
- Re: SystemRoot: XP vs VISTA
- References:
- SystemRoot: XP vs VISTA
- From: Tom de Neef
- SystemRoot: XP vs VISTA
- Prev by Date: Re: Turbo
- Next by Date: Re: SystemRoot: XP vs VISTA
- Previous by thread: Re: SystemRoot: XP vs VISTA
- Next by thread: Re: SystemRoot: XP vs VISTA
- Index(es):
Relevant Pages
|