> Hey, I found out about your projects and WinPCap a little 
> while ago. So far, 
> I can see all of you have put forth a lot of effort into 
> making this. I had 
> a few questions though, since I'm not really a proficient C++ 
> User. I do 
> have C++, and all the example files work, but I wanted to 
> know if it was 
> possible to use WPCap.dll or Packet.dll in Visual Basic using 
> API calls. I 
> have tried to convert some of the C++ API to VB, but it just 
> doesn't seem to 
> work. Here is an example:
> 
> Private Declare Function PacketGetAdapterNames Lib 
> "packet.dll" (pStr As 
> String, BufferSize As Long) As Boolean
> 
> I thought this would be a correct API call, but it seems to 
> have errors when 
> I call it. If anyone could help me on this issue, I would 
> greatly appriciate 
> it. Thanks!

C function
BOOLEAN PacketGetAdapterNames (PTSTR pStr, PULONG BufferSize)

Would translate to
Private Declare Function PacketGetAdapterNames lib "packet.dll"
 (byval pStr as String, byref BufferSize as long) as long

One big thing with VB is that it _doesn't_ support multi-threading. Multi
threading happens if you use callback functions (like pcap_loop).

Translating functions from C to VB is easy when you remember few simple
things:
 - ByVal = direct value
 - ByRef = pointer to value (usually P or LP in front of C type)
 - With strings byval = pointer to string, byref = pointer to pointer to
string
 - PTSTR = pointer to string = byval string
 - PULONG = pointer to long = byref long
 - BOOLEAN = long
 - Nearly everything are longs
 - C int = VB long
 - C short = VB integer


Following might work.

Public Type PACKET
 hEvent as long
 Overlapped as long
 Buffer as byte*1048576
 Length as long
 BytesReceived as long
 bIoComplete as long
End Type

Private Declare Function PacketReceivePacket lib "packet.dll" (byref Adapter
as ADAPTER, byref Packet as PACKET, sync as long) as long

But it might not work because you "need" to use PakcetAllocatePacket &
PacketInitPacket... Maybe 'Dim lppacket as long' might work...

In short: It can be done but it is a real pain because VB doesn't have
pointers. (Like C/C++ has)

Anssi Kolehmainen



==================================================================
 This is the WinPcap users list. It is archived at
 http://www.mail-archive.com/[EMAIL PROTECTED]/

 To unsubscribe use 
 mailto: [EMAIL PROTECTED]
==================================================================

Reply via email to