deviceiocontrol(200分)

  • 主题发起人 主题发起人 hpd
  • 开始时间 开始时间
H

hpd

Unregistered / Unconfirmed
GUEST, unregistred user!
function TForm1.BindNic(hVxd: THandle; Ndis: string): Boolean;<br>var<br>&nbsp; hEvent: THandle;<br>&nbsp; cbRet: DWORD;<br>&nbsp; ovlp: POVERLAPPED;<br>&nbsp; cbIn: DWORD;<br>&nbsp; RetVal: boolean;<br>&nbsp; inbuffer: PAnsiChar;<br>&nbsp; errorcode,temp: Dword;<br>begin<br>&nbsp; hEvent:= CreateEvent(nil, True, false, nil);<br>&nbsp; new(ovlp);<br>&nbsp; ovlp.Internal := 0;<br>&nbsp; ovlp.InternalHigh:= 0;<br>&nbsp; ovlp.Offset:=0;<br>&nbsp; ovlp.OffsetHigh:=0;<br>&nbsp; ovlp.hEvent:=hEvent ;<br>&nbsp; cbIn:= 5;<br>&nbsp; inbuffer:=PChar(ndis);<br><br>&nbsp; RetVal:= DeviceIoControl (hVxd, IOCTL_PROTOCOL_BIND, inbuffer, cbIn, inbuffer, cbIn, cbRet, ovlp);<br>&nbsp; ErrorCode:=getlasterror();<br><br>-------------------- <br>RetVal总是得到false, <br>ErrorCode=87 <br>查手册87意为参数错误. <br>其中ioctl_protocol_bind=$8000001c <br><br>请大虾出手!!!
 
If the overlapped operation cannot be completed immediately, the<br>function returns FALSE, and GetLastError returns ERROR_IO_PENDING, <br>indicating that the operation is executing in the background.<br><br>When this happens, the operating system sets the event object in the <br>OVERLAPPED structure to the nonsignaled state before DeviceIoControl <br>returns. The system then sets the event object to the signaled state <br>when the operation has been completed.<br>The calling thread can use any of the wait functions to wait for the <br>event object to be signaled, and then use the GetOverlappedResult <br>function to determine the results of the operation. The GetOverlappedResult<br>function reports the success or failure of the operation and the <br>number of bytes returned in the lpOutBuffer buffer.
 
huizhang:<br>&nbsp; 你好,<br>&nbsp; RetVal总是得到false, <br>&nbsp; ErrorCode=87---error_invaild_parametres <br>&nbsp; 似乎为参数错误. <br>&nbsp; 而不是Error_io_pending.
 
huizhang老师,这个问题还得您来解决。
 
这个问题请晓茶删除吧, 我也解决不了, 那个ioctl_protocol_bind找不到任何说明<br>不知道相应的参数如何设置, 而且hVXD是什么设备也不清楚。
 
你的这段程序没有任何错误!<br>唯一应该注意的是调用的时候:<br>应该用:<br>var <br>Myndis: string;<br>begin<br>......<br>&nbsp; &nbsp; Myndis:='0002';<br>&nbsp; &nbsp; Bind(hVxd,Myndis);<br>......<br>end<br>不能直接用Bind(hVxd,'0002')方式调用。<br>希望对你有用<br>我已经调试通过了,运行正常。
 
我想可能是在调用DeviceIoControl没有将Inbuffer的空间设定好,因为DELPHI中<br>的字符串的内存分配是用时分配的,可以用SetLength函数设定Inbuffer的空间大小。以上是我个人的愚见,请勿见笑。
 
可以接受答案了吧?<br>hpd的目的是将IPMAN的C程序翻译到DELPHI<br>hpd的程序我将调用方法改了以后,运行后<br>可以监听网络的信息。<br><br>ioctl_protocol_bind是IPMAN的VXD与网卡绑定<br>的功能号。<br>HVXD是Vpacket.vxd装入后的句柄<br>在此要非常感谢茶叶蛋发给我的程序。<br>
 
茶老兄的程序能给我一份吗?<br>谢谢!!!
 
茶老兄:把程序给我一份吧!我好给大虾们分配分数,谢谢!
 
多人接受答案了。
 

Similar threads

I
回复
0
查看
759
import
I
I
回复
0
查看
582
import
I
I
回复
0
查看
611
import
I
I
回复
0
查看
706
import
I
后退
顶部