unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TfrmMain =
class(TForm)
gboxWatchdog: TGroupBox;
gboxIOOperations: TGroupBox;
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
public
end;
type
PWDTPARAM = ^WDTPARAM;
WDTPARAM =
record
timeout: Byte;
data_b: Byte;
end;
const
WDT_TYPE = $88B9;
//35001;
WDT_DEVICE = '
\\.\WDT_DEVICE';
WDT_DEVICE_NAME = '
\Device\WDT_DEVICE';
WDT_DOS_DEVICE_NAME = '
\DosDevices\WDT_DEVICE';
IOCTL_SYS_WDT_SET_TIMEOUT = DWORD((WDT_TYPE
shl 16)
or (2
shl 14)
or ($800
shl 2)
or 0);
IOCTL_SYS_WDT_START = DWORD((WDT_TYPE
shl 16)
or (2
shl 14)
or ($801
shl 2)
or 0);
IOCTL_SYS_WDT_STOP = DWORD((WDT_TYPE
shl 16)
or (2
shl 14)
or ($802
shl 2)
or 0);
IOCTL_SYS_WDT_RESTART = DWORD((WDT_TYPE
shl 16)
or (2
shl 14)
or ($803
shl 2)
or 0);
IOCTL_SYS_DIO_READ = DWORD((WDT_TYPE
shl 16)
or (2
shl 14)
or ($804
shl 2)
or 0);
IOCTL_SYS_DIO_WRITE = DWORD((WDT_TYPE
shl 16)
or (2
shl 14)
or ($805
shl 2)
or 0);
var
frmMain: TfrmMain;
implementation
{$R *.DFM}
procedure TfrmMain.Button1Click(Sender: TObject);
var
hDIO: THandle;
cParam: WDTPARAM;
nReturn: DWORD;
begin
hDIO := CreateFile(WDT_DEVICE, GENERIC_READ
OR GENERIC_WRITE, FILE_SHARE_READ
OR
FILE_SHARE_WRITE,
NIL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL
OR
FILE_FLAG_NO_BUFFERING, 0);
if hDIO <> INVALID_HANDLE_VALUE
then
begin
cParam.timeout := 0;
cParam.data_b := Byte(StrToIntDef('
$' + Edit1.Text, 0));
DeviceIoControl(hDIO, IOCTL_SYS_DIO_WRITE, @cParam, SizeOf(cParam),
nil, 0, nReturn,
nil);
CloseHandle(hDIO);
end
else begin
MessageDlg('
Fehler, kein (gültiges) Handle!', mtWarning, [mbOK], 0);
end;
end;
end.