var<br> Buffer : PByteArray;<br> BufferSize : Integer;<br> s : String;<br> i : Integer;<br>begin<br> with TRegistry.Create do try<br> RootKey:=HKey_LOCAL_Machine;<br> OpenKey('Software/Microsoft/Windows/Currentversion',False);<br> try<br> BufferSize:=GetDataSize('FirstInstallDateTime');<br> GetMem(Buffer,BufferSize);<br> try<br> ReadBinaryData('FirstInstallDateTime',Buffer^,BufferSize);<br> s:='';<br> for i:=0 to BufferSize-1 do<br> s:=Format('%s%.2x ',[s,Buffer^]);<br> Delete(s,Length(s),1);<br> Label1.Caption:=s;<br> finally<br> FreeMem(Buffer,BufferSize);<br> end;<br> finally<br> CloseKey;<br> end;<br> finally<br> Free;<br> end;<br>end;<br><br>//////////////////////////////////////////////////////////<br><br>function DateInstallWindows (var DateInstall: TDateTime):Boolean; <br>var <br> RegDate: TRegistry; <br> Buffer: Integer; <br>begin <br>Result:=False; <br>RegDate := TRegistry.Create; <br>try <br> RegDate.RootKey := HKEY_LOCAL_MACHINE; <br> if Win32Platform = VER_PLATFORM_WIN32_NT Then <br> Begin <br> if RegDate.OpenKey('Software/Microsoft/Windows NT/CurrentVersion', True) <br> then <br> Begin <br> RegDate.ReadBinaryData('InstallDate',Buffer, sizeof (Buffer)); <br> DateInstall:=StrToDateTime (FormatDateTime('dd/mm/yyyy hh:nn', FileDateToDateTime(Buffer))); <br> Result:=True; <br> end <br> end <br> else <br> if RegDate.OpenKey('Software/Microsoft/Windows/CurrentVersion', True) <br> then <br> Begin <br> RegDate.ReadBinaryData('FirstInstallDateTime',Buffer, sizeof (Buffer)); <br> DateInstall:=StrToDateTime (FormatDateTime('dd/mm/yyyy hh:nn', FileDateToDateTime(Buffer))); <br> Result:=True; <br> end <br> finally <br> RegDate.CloseKey; <br> RegDate.Free; <br> end; <br>end; <br><br>2.用法<br><br>procedure TForm1.BitBtn2Click(Sender: TObject); <br>var <br> TheDate: TDateTime; <br>begin <br>if DateInstallWindows (TheDate) Then Label1.Caption:=DateTimeToStr (TheDate); <br>end;