procedure TfrmDateTime.GetKeyValues; const MasterKey='\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones'; var ARegistry:TRegistry; SubKeys:TStrings; i:Integer; begin ARegistry:=TRegistry.Create; ARegistry.RootKey:=HKEY_LOCAL_MACHINE; if not ARegistry.OpenKeyReadOnly(MasterKey) then exit; SubKeys:=TStringList.Create; ARegistry.GetKeyNames(SubKeys); ARegistry.CloseKey; SubKeys.Free; ARegistry.Free; end;
在9x是放在 HKEY_LOCAL_MACHINE \Software\Microsoft\Window s\CurrentVersion\Time Zones底下而在NT是放在 HKEY_LOCAL_MACHINE \Software\Microsoft\Window s NT\CurrentVersion\Time Zones底下
const
MasterKey='\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones';
var
ARegistry:TRegistry;
SubKeys:TStrings;
i:Integer;
begin
ARegistry:=TRegistry.Create;
ARegistry.RootKey:=HKEY_LOCAL_MACHINE;
if not ARegistry.OpenKeyReadOnly(MasterKey) then exit;
SubKeys:=TStringList.Create;
ARegistry.GetKeyNames(SubKeys);
ARegistry.CloseKey;
SubKeys.Free;
ARegistry.Free;
end;
取得这些键值后就可以通过GetTimeZoneInformation,SetTimeZoneInformation来取得并设定时区