Hmm..
So, mal ein bischen recherchiert...
'InstallTime' gibt es nur mit Windows10..
Es ist ein REG_QWORD, somit 64Bit Integer und enthält einen LDAP/FileTime TimeStamp.
Dieser passt unter D6 in einen Int64.
Ich musste meinem D6 erst das Lesen von REG_QWORD beibringen und konnte dann die Zahl mit FileTimeToDateTime in einen DateTime konvertieren.
Delphi-Quellcode:
uses
Registry, RTLConsts, DateUtils;
const
KEY_WOW64_64KEY = $0100;
KEY_WOW64_32KEY = $0200;
const
REG_QWORD = 11;
function FileTimeToDateTime(ft: TFileTime): TDateTime; overload;
var
tzi: TTimeZoneInformation;
lt, st: TSystemTime;
begin
GetTimeZoneInformation(tzi);
FileTimeToSystemTime(ft, st);
SystemTimeToTzSpecificLocalTime(@tzi, st, lt);
Result := SystemTimeToDateTime(lt);
end;
function FileTimeToDateTime(ft_Int: Int64): TDateTime; overload;
var
ft: TFileTime;
begin
Int64(ft) := ft_Int;
Result := FileTimeToDateTime(ft);
end;
type
TRegistryEx = class(TRegistry)
public
function ReadInt64(const Name: String): Int64;
procedure WriteInt64(const Name: String; Value: Int64);
end;
{ TRegistryEx }
function TRegistryEx.ReadInt64(const Name: String): Int64;
var dwType: DWORD;
dwSize: DWORD;
begin
dwType:=REG_NONE;
dwSize:=SizeOf(Int64);
if (RegQueryValueEx(CurrentKey, PChar(Name), nil, @dwType, PByte(@result), @dwSize) <> ERROR_SUCCESS) then
raise ERegistryException.CreateResFmt(@SRegGetDataFailed, [Name]);
if (dwType <> REG_QWORD) then raise ERegistryException.CreateResFmt(@SInvalidRegType, [Name]);
end;
procedure TRegistryEx.WriteInt64(const Name: String; Value: Int64);
var dwType: DWORD;
dwSize: DWORD;
begin
dwType:=REG_QWORD;
dwSize:=SizeOf(Int64);
if (RegSetValueEx(CurrentKey, PChar(Name), 0, dwType, @Value, dwSize) <> ERROR_SUCCESS) then
raise ERegistryException.CreateResFmt(@SRegSetDataFailed, [Name]);
end;
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
Reg: TRegistryEx;
tmpInstallDate : Cardinal;
tmpInstallTime : Int64;
begin
tmpInstallDate := 0;
tmpInstallTime := 0;
Reg := TRegistryEx.Create(KEY_WOW64_64KEY or KEY_ALL_ACCESS);
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('\Software\Microsoft\Windows NT\CurrentVersion', False) then
begin
tmpInstallDate := Reg.ReadInteger('InstallDate');
if Reg.ValueExists('InstallTime') then
tmpInstallTime := Reg.ReadInt64('InstallTime');
Reg.CloseKey;
end;
finally
Reg.Free;
end;
Edit1.Text := DateTimeToStr(UnixToDateTime(tmpInstallDate));
Edit2.Text := DateTimeToStr(FileTimeToDateTime(tmpInstallTime));
end;
Der Source für TRegistryEx stammt von hier:
https://www.experts-exchange.com/que...-registry.html
Den Link zum FileTimeToDateTime mit Int64 habe ich leider verdaddelt...