SELECT * INTO < new_table > FROM < existing_table > WHERE < clause >
You can use the Windows API call to GetProcessTimes (declared in Windows.pas) to get details for any process.
If it's your application, I would probably get the start time myself and log it somewhere to keep a history.
Используйте NtQuerySystemInformation с информационным классом SystemProcessInformation, это возвращает массив структур (записей) SYSTEM_PROCESSES, из которых CreateTime содержит точное время, когда приложения были запущены:
_SYSTEM_PROCESSES = record // Information Class 5
NextEntryDelta: ULONG;
ThreadCount: ULONG;
Reserved1: array[0..5] of ULONG;
CreateTime: LARGE_INTEGER;
UserTime: LARGE_INTEGER;
KernelTime: LARGE_INTEGER;
ProcessName: UNICODE_STRING;
BasePriority: KPRIORITY;
ProcessId: ULONG;
InheritedFromProcessId: ULONG;
HandleCount: ULONG;
// next two were Reserved2: array [0..1] of ULONG; thanks to Nico Bendlin
SessionId: ULONG;
Reserved2: ULONG;
VmCounters: VM_COUNTERS;
PrivatePageCount: ULONG;
IoCounters: IO_COUNTERSEX; // Windows 2000 only
Threads: array[0..0] of SYSTEM_THREADS;
end;
SYSTEM_PROCESSES = _SYSTEM_PROCESSES;
PSYSTEM_PROCESSES = ^SYSTEM_PROCESSES;
TSystemProcesses = SYSTEM_PROCESSES;
PSystemProcesses = PSYSTEM_PROCESSES;
Мы уже перевели все это в Jedi Apilib (JwaNative)
I'm not sure if there's a function or API call for this. But you can fake it pretty easily. Create a unit that looks like this:
unit AppStartTime;
interface
function GetAppStartTime: TDateTime;
implementation
uses
SysUtils;
var
fStartTime: TDateTime;
function GetAppStartTime: TDateTime;
begin
result := fStartTime;
end;
initialization
fStartTime := Now;
end.
Add it to your DPR's uses list, at the top, either first or immediately after anything that "must be first on the list", such as a custom memory manager.
You can have your app log the startup time to a text file or database either in the DPR file or in your main form's OnCreate() event. You can use Delphi's Now() function to get the current date and time, and format it as a string using FormatDateTime() or DateTimeToStr(), depending on what exactly you're looking to do.
The code below saves the startup date and time during the main form's constructor to a text file in the same folder as the application itself called StartDateTime.txt:
procedure TForm1.FormCreate(Sender: TObject);
var
SL: TStringList;
begin
SL := TStringList.Create;
try
SL.Add(FormatDateTime('mm/dd/yyyy hh:nn:ss', Now());
SL.SaveToFile(ExtractFilePath(ParamStr(0)) + 'StartDateTime.txt');
finally
SL.Free;
end;
end;