roboforum.ruТехнический форум по робототехнике. |
|
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
function WUSB_Open():Longint; cdecl; external 'WUSBdrv.dll';
function WUSB_SetupPortA(iomsk: Byte):Longint; cdecl; external 'WUSBdrv.dll';
function WUSB_WritePortA(value: Byte):Longint; cdecl; external 'WUSBdrv.dll';
function WUSB_ReadPortA(value: Pointer):Longint; cdecl; external 'WUSBdrv.dll';
type
TForm1 = class(TForm)
.........
procedure TForm1.Button1Click(Sender: TObject);
var
status: Longint;
begin
status:=WUSB_Open();
if status = 1 then
begin
MessageDlg('Open Ok', mtInformation, [mbOK], 0);
end
else
begin
MessageDlg('Open Error...', mtError, [mbOK], 0);
end
end;
procedure TForm1.Button2Click(Sender: TObject);
var
status: Longint;
begin
status := WUSB_SetupPortA(StrToInt(Edit1.Text));
if status = 0 then
begin
MessageDlg('Setup Error', mtInformation, [mbOK], 0);
end
else
begin
MessageDlg('Setup OK', mtInformation, [mbOK], 0);
end
end;
procedure TForm1.Button3Click(Sender: TObject);
var
status: Longint;
begin
status := WUSB_WritePortA(StrToInt(Edit2.Text));
if status = 0 then
begin
MessageDlg('Write Error', mtInformation, [mbOK], 0);
end
end;
procedure TForm1.Button4Click(Sender: TObject);
var
status: Longint;
data: Byte;
begin
status := WUSB_ReadPortA(@data);
if status = 0 then
begin
MessageDlg('Read Error', mtInformation, [mbOK], 0);
end
else
begin
Edit3.Text:= IntToStr(data);
end
end;
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 5