Nachtrag für
Win9x (ab Win95, erste Version, ohne Updates)
Delphi-Quellcode:
function GetWindowsInstallDateTime: TDateTime;
const
RegKeyNT = 'SOFTWARE\Microsoft\Windows NT\CurrentVersion';
RegValNT = 'InstallDate';
RegKey95 = 'SOFTWARE\Microsoft\Windows\CurrentVersion';
RegVal95 = 'FirstInstallDateTime';
function RegReadDWORD(const Key, Name: string): DWORD;
begin
Result := 0;
with TRegistry.Create do
try
RootKey := HKEY_LOCAL_MACHINE;
if KeyExists(Key) and OpenKeyReadOnly(Key) and ValueExists(Name) and
(GetDataType(Name) in [rdInteger, rdBinary, rdUnknown]) and
(GetDataSize(Name) = SizeOf(Result)) then
if GetDataType(Name) = rdInteger then
Result := DWORD(ReadInteger(Name))
else
ReadBinaryData(Name, Result, SizeOf(Result));
finally
Free;
end;
end;
var
Value: DWORD;
begin
Value := RegReadDWORD(RegKeyNT, RegValNT);
if Value <> 0 then
Result := EncodeDate(1970, 1, 1) + (Value / SecsPerDay)
else
begin
Value := RegReadDWORD(RegKey95, RegVal95);
if Value <> 0 then
Result := FileDateToDateTime(Value)
else
Result := 0.0;
end;
end;
////////////////////////////////////////////////////////////////////////////////
// Beispiel
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(FormatDateTime('yyyy-mm-dd hh:nn:ss', GetWindowsInstallDateTime));
end;
Viel Spass