unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit6: TEdit;
Label6: TLabel;
Label7: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
hTimer: THandle;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
_SetSuspendState:
function (Hibernate, ForceCritical, DisableWakeEvent: BOOL): BOOL
stdcall;
implementation
{$R *.dfm}
function LinkAPI(
const module, functionname:
string): Pointer;
var
hLib: HMODULE;
begin
hLib := GetModulehandle(PChar(module));
if hLib = 0
then
hLib := LoadLibrary(PChar(module));
if hLib <> 0
then
Result := getProcAddress(hLib, PChar(functionname))
else
Result :=
nil;
end;
function SetSuspendState(Hibernate, ForceCritical,
DisableWakeEvent: Boolean): Boolean;
begin
if not Assigned(_SetSuspendState)
then
@_SetSuspendState := LinkAPI('
POWRPROF.dll', '
SetSuspendState');
if Assigned(_SetSuspendState)
then
Result := _SetSuspendState(Hibernate, ForceCritical,
DisableWakeEvent)
else
Result := False;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
liDuTime:LARGE_INTEGER;
weckzeit:SYSTEMTIME;
ftime:FILETIME;
fitime:FILETIME;
begin
weckzeit.wYear:=strtoint(edit1.text);
weckzeit.wMonth:=strtoint(edit2.text);
weckzeit.wDayOfWeek:=strtoint(edit4.text);
weckzeit.wDay:=strtoint(edit3.text);
weckzeit.wHour:=strtoint(edit5.text);
weckzeit.wMinute:=strtoint(edit6.text);
weckzeit.wSecond:=0;
weckzeit.wMilliseconds:=0;
SystemTimeToFileTime(weckzeit,ftime);
LocalFileTimeToFileTime(ftime,fitime);
liDuTime.LowPart:=fitime.dwLowDateTime;
liDuTime.HighPart:=fitime.dwHighDateTime;
hTimer:=CreateWaitableTimer(
NIL,TRUE,
NIL);
CancelWaitableTimer(htimer);
SetWaitableTimer(hTimer,lidutime.quadpart,1000,
NIL,
NIL,true);
SetSuspendState(true,true,false);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.text:='
2009';
Edit2.text:='
11';
Edit3.text:='
5';
Edit4.text:='
4';
Edit5.text:='
20';
Edit6.text:='
55';
end;
end.