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);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
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;
hDIO: THandle;
cParam: WDTPARAM;
nReturn: DWORD;
implementation
{$R *.DFM}
procedure TfrmMain.Button1Click(Sender: TObject);
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 > 0)
then
begin
try
cParam.data_b := Byte(StrToInt('
$' + Edit1.Text));
except
cParam.data_b := Byte(StrToInt('
$' + '
0'));
end;
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.