14. marts 2003 - 16:17Der er
9 kommentarer og 1 løsning
Sleep-Timer
Halløjsa, er det ikke muligt at lave en sleep-timer, altså lad os sige 25min frem, og så lukker programmet alt hvad der er åben, og den lukker windows..
type TForm1 = class(TForm) Button1: TButton; Timer1: TTimer; procedure Button1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1; Sluttid: TDateTime;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); begin Sluttid := Time + StrToTime('00:00:10'); // her ligger jeg 10 sek til if timer1.Enabled then timer1.Enabled := False else timer1.Enabled := true end;
procedure TForm1.Timer1Timer(Sender: TObject); begin IF TimeToStr( Time - slutTid ) = '00:00:00' THEN BEGIN form1.close; // programmer lukker, når programmer er nået det antal sek eller min og timer.
END; end;
end.
---slut kode---
Skriv hvis det er. Jeg har også et api kald som lukker windows. Hvis du ikke har et.-
procedure RebootSystem; begin ExitWindowsEx(EWX_REBOOT (* + EWX_FORCE hvis det er*), 0); // Reboot you system end;
EWX_FORCE Forces processes to terminate. Instead of bringing up the "application not responding" dialog box for the user, this value forces an application to terminate if it does not respond.
EWX_LOGOFF Shuts down all processes running in the security context of the process that called the ExitWindowsEx function. Then it logs the user off.
EWX_POWEROFF Shuts down the system and turns off the power. The application must have the SE_SHUTDOWN_NAME privilege (for more information, see the Remarks section) and the system must support the power-off feature.
EWX_REBOOT Shuts down the system and then restarts the system. The application must have the SE_SHUTDOWN_NAME privilege (for more information, see the Remarks section).
EWX_SHUTDOWN Shuts down the system to a point at which it is safe to turn off the power. All file buffers have been flushed to disk, and all running processes have stopped. The application must have the SE_SHUTDOWN_NAME privilege (for more information, see the Remarks section).
Jeg har lidt travelt med arbjede/studier lige i øjeblikket, derfor har jeg ikke haft tid til at afprøve dem.. Men satser på at gøre det i løbet af weekenden...
Mvh Johnny..
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.