Hi,
Mit GetProcessTimes() kannst du u.a die Zeit/Datum auslesen, an welchem ein Prozess
gestartet wurde.
Hab das mal in einer Funktion gekapselt:
Delphi-Quellcode:
function ApplicationCreationTime(hProcess: THandle): TDateTime;
var
ft_CreationTime, lpExitTime, ft_KernelTime, ft_UserTime: TFileTime;
dft: DWORD;
function FileTimeToDateTime(ft: TFileTime): TDateTime;
var
ft1: TFileTime;
st: TSystemTime;
begin
if ft.dwLowDateTime + ft.dwHighDateTime = 0 then
Result := 0
else
begin
FileTimeToLocalFileTime(ft, ft1);
FileTimeToSystemTime(ft1, st);
Result := SystemTimeToDateTime(st);
end;
end;
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then
if GetProcessTimes(hProcess, ft_CreationTime, lpExitTime,
ft_KernelTime, ft_UserTime) then
begin
Result := FileTimeToDateTime(ft_CreationTime);
end
else
RaiseLastOSError;
end;
Bsp: Creationtime des eigenen Prozesses anzeigen:
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
label1.Caption:=DateTimeToStr(ApplicationCreationTime(GetCurrentProcess));
end;