请问各路高手,我现在用API是writefile想控制并口某个引脚的电平输出值是高电平还是低电平,应该怎么做?
我写的几句:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
handle :integer;
lrc:longWord;
temp :byte;
begin
temp:=00000000;
handle := CreateFile('LPT1',$40000000,0,0,3,0,0);
if (handle <> 0 ) then
writefile(handle,Pchar(temp)^,0,lrc,0);//送出数据
CloseHandle(handle);
end;
这样好象不行???????writefile里面的参数应该怎么样设置?????
我写的几句:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
handle :integer;
lrc:longWord;
temp :byte;
begin
temp:=00000000;
handle := CreateFile('LPT1',$40000000,0,0,3,0,0);
if (handle <> 0 ) then
writefile(handle,Pchar(temp)^,0,lrc,0);//送出数据
CloseHandle(handle);
end;
这样好象不行???????writefile里面的参数应该怎么样设置?????
如果再加点外部电路,用EPP模式可以做到。
需要直接访问IO才行,而不是使用Windows中的设备。
http://www.fapo.com/eppmode.htm
SPP模式
http://www.theiling.de/parport/centronics.html
相关搜索
http://www.google.cn/search?complete=1&hl=zh-CN&newwindow=1&q=SPP+interface+IEEE&meta=
function GetPortVal(PortAddr:integer; PortVal:pointer; bSize:Byte): Boolean; stdcall; external 'winio.dll'function SetPortVal(PortAddr:integer;PortVal:DWORD;bSize:BYTE):Boolean;stdcall;external 'WinIo.dll' name 'SetPortVal'
Function InitializeWinIo():Boolean;stdcall;external 'WinIo.dll'; //载入判断 Function ShutdownWinIo():Boolean;stdcall;external 'WinIo.dll'; //将它关闭
下面是写端口:
function TfrmMain.setport: boolean;
begin
//ture为低电平,并口的第十四针脚
Result:=SetPortVal($37A, $2, 1); //写端口 (端口地址 , 端口值 ,1)
end;
这样就OK了,想恢复高电平调用另一个借口就行了.可能也是和你说的那个外部电路是相同的吧.........多谢ahjoe(强哥) !!