Diskuze: Dĺžka behu aplikácie

Tvůrce

Zobrazeno 17 zpráv z 17.
//= Settings::TRACKING_CODE_B ?> //= Settings::TRACKING_CODE ?>
Začneš měřit čas, spustíš program, počkáš až program skončí a
stopneš čas a máš změřeno.
V C# třeba takhle:
http://support.microsoft.com/kb/305369
Hm, treba http://www.delphidabbler.com/tips/17
Cela ta funkce nejspis jen spusti exac, kterej ji zadas a ceka, dokud ho
nevypnes. Asi je tam preklep, misto "PChar(fsExe)" ma asi byt "PChar(sExe)"
jinak myslim, ze ten vnitrek ani nejak detailne chapat nepotrebujes, kdyztak si
ty funkce postupne vygoogli, myslim, ze to pak pochopis.
Prvni asi jmeno EXE souboru, druhej asi parametry (muzes nechat prazdne).
Ty errory většinou na něco upozorňují, je dobré se nad nimi zamyslet
nebo je sem poslat
no to ano, len pri takom mnozstve mi z toho zamyslenia vychadza len to ze tej funkcii chyba kniznica ...
unit1.pas(40,14) Error: Identifier not found "ExecAndWait"
unit1.pas(40,21) Error: Identifier not found "skuska"
unit1.pas(54,34) Error: Identifier not found "TProcessInformation"
unit1.pas(54,34) Error: Error in type definition
unit1.pas(58,22) Hint: Local variable "tsiStartup" does not seem to be initialized
unit1.pas(60,19) Error: Identifier not found "CreateProcess"
unit1.pas(61,30) Error: Identifier not found "tpi"
unit1.pas(63,22) Error: Identifier not found "WAIT_OBJECT_0"
unit1.pas(63,43) Error: Identifier not found "WaitForSingleObject"
unit1.pas(63,55) Error: Illegal qualifier
unit1.pas(63,73) Error: Identifier not found "INFINITE"
unit1.pas(65,28) Error: Identifier not found "GetExitCodeProcess"
unit1.pas(65,40) Error: Illegal qualifier
unit1.pas(67,12) Warning: Local variable "dwExitCode" does not seem to be initialized
unit1.pas(70,23) Error: Identifier not found "SetLastError"
unit1.pas(73,31) Error: Identifier not found "GetLastError"
unit1.pas(74,16) Error: Identifier not found "CloseHandle"
unit1.pas(74,28) Error: Illegal qualifier
unit1.pas(75,16) Error: Identifier not found "CloseHandle"
unit1.pas(75,28) Error: Illegal qualifier
unit1.pas(76,17) Error: Identifier not found "SetLastError"
unit1.pas(82) Fatal: There were 19 errors compiling module, stopping
teraz ma este napada ze problem moze byt v tom ze robim v lazaruse a nie v delphi
mozna ti chybi neco v uses, zkus ty prikazy jeden po druhym vyhledat, kam
patrej
uz sa to zredukovalo na
unit1.pas(40,14) Error: Identifier not found "ExecAndWait"
unit1.pas(40,21) Error: Identifier not found "skuska"
unit1.pas(58,22) Hint: Local variable "tsiStartup" does not seem to be initialized
unit1.pas(61,30) Error: Identifier not found "tpi"
unit1.pas(63,44) Warning: Local variable "tpiProcess" does not seem to be initialized
unit1.pas(65,60) Hint: Local variable "dwExitCode" does not seem to be initialized
unit1.pas(82) Fatal: There were 3 errors compiling module, stopping
ale toto uz nebude kniznicou...
kod vyzera takto
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ExtCtrls, shellapi, windows;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
tick: integer=0;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.enabled:=true;
ExecAndWait('skuska.exe');
timer1.enabled:=false;
label1.caption:=inttostr(tick);
tick:=0;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
inc(tick);
end;
function ExecAndWait(sExe, sCommandLine: string): Boolean;
var
dwExitCode: DWORD;
tpiProcess: TProcessInformation;
tsiStartup: TStartupInfo;
begin
Result := False;
FillChar(tsiStartup, SizeOf(TStartupInfo), 0);
tsiStartup.cb := SizeOf(TStartupInfo);
if CreateProcess(PChar(sExe), PChar(sCommandLine), nil, nil, False, 0,
nil, nil, tsiStartup, tpi) then
begin
if WAIT_OBJECT_0 = WaitForSingleObject(tpiProcess.hProcess, INFINITE) then
begin
if GetExitCodeProcess(tpiProcess.hProcess, dwExitCode) then
begin
if dwExitCode = 0 then
Result := True
else
SetLastError(dwExitCode + $2000);
end;
end;
dwExitCode := GetLastError;
CloseHandle(tpiProcess.hProcess);
CloseHandle(tpiProcess.hThread);
SetLastError(dwExitCode);
end;
end;
end.
Chybi ti deklarace funkce ExecAndWait nekde na zacatku, hod to treba za globalni var.
toto vyzera tiez slubne ale neviem to rozbehat http://www.tek-tips.com/viewthread.cfm?…
Zobrazeno 17 zpráv z 17.