この単純なVBアプリケーションとライブラリは、0x378ベースアドレスのプリンタポートに接続されたドア/ターンスタイルを開くことができると言われています。
'Inp and Out declarations for port I/O using inpout32.dll.
Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" _
(ByVal PortAddress As Integer) _
As Integer
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" _
(ByVal PortAddress As Integer, _
ByVal Value As Integer)
------------------------------------------------------------------------------------
Option Explicit
Dim Value As Integer
Dim PortAddress As Integer
Private Sub cmdWriteToPort_Click()
'Write to a port.
Out PortAddress, Value
'Read back and display the result.
Text1.Text = Inp(PortAddress)
Value = Value + 1
If Value = 255 Then Value = 0
End Sub
Private Sub Form_Load()
'Test program for inpout32.dll
Value = 0
'Change PortAddress to match the port address to write to:
'(Usual parallel-port addresses are &h378, &h278, &h3BC)
PortAddress = &H378
End Sub
ただし、アプリケーションに統合するには、Delphi5で書き直す必要があります。
- D5を介して同じライブラリにアクセスすることは可能ですか?
- 私は次のコードで正しい方向に進んでいますか?
//ライブラリを使用したポートI/OのInpおよびOut宣言
function Inp(PortAddress:String); external 'inpout32.dll.dll'
begin
return ??
end;
procedure Output(PortAddress:String;Value:Integer); external 'inpout32.dll.dll'
procedure TForm1.FormActivate(Sender: TObject);
begin
//Test program for inpout32.dll
Value := 0;
//Change PortAddress to match the port address to write to:
//(Usual parallel-port addresses are &h378, &h278, &h3BC)
PortAddress := '&H378';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
//Write to a port.
Output(PortAddress, Value);
//Read back and display the result.
Edit1.Text := Inp(PortAddress);
Value := Value + 1;
if Value = 255 then
Value := 0;
end;
ライブラリ関数を宣言する方法と変数を宣言する方法が正確にわかりません(&H378は明らかに整数ではありません)
ありがとう