function GetLastKeyAccess(
const AhRootKey : HKEY;
const AsSubKey :
string;
var AsResult :
string) : boolean;
var
hResult : HKEY;
ftLastWrite : FILETIME;
ft : FILETIME;
st : SYSTEMTIME;
begin
if RegOpenKeyEx(AhRootKey,PChar(AsSubKey),0,KEY_READ,hResult) <> ERROR_SUCCESS
then begin
AsResult := '
ERROR OPEN: '+SysErrorMessage(GetLastError);
Result := False;
Exit;
end;
try
if RegQueryInfoKey(hResult,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,@ftLastWrite) <> ERROR_SUCCESS
then begin
AsResult := '
ERROR QUERY: '+SysErrorMessage(GetLastError);
Result := False;
end;
if not FileTimeToLocalFileTime(ftLastWrite,ft)
then begin // An Zeitzone anpassen
AsResult := '
ERROR CONVERT FT: '+SysErrorMessage(GetLastError);
Result := False;
Exit;
end;
FillChar(st,SizeOf(st),0);
if not FileTimeToSystemTime(ft,st)
then begin // Zur Ausgabe umwandeln
AsResult := '
ERROR CONVERT ST: '+SysErrorMessage(GetLastError);
Result := False;
Exit;
end;
AsResult := Format('
%.2d.%.2d.%.4d %.2d:%.2d:%.2d,%.3d',[st.wDay,st.wMonth,st.wYear,st.wHour,st.wMinute,st.wSecond,st.wMilliseconds]);
Result := True;
finally
RegCloseKey(hResult);
end;
end;