TCP

Started by Roger Garstang, July 14, 2004, 05:35:20 AM

Previous topic - Next topic

Roger Garstang

Lets face it, PB's TCP commands are horrible.  Wrapper functions for Winsock, etc from someone that knows how to use them would be awesome.  I don't know what the deal is with PB's, but no matter how many people there say they use them everyday...they still don't work.  There are numerous reports of not getting complete results back (EOF too soon, etc) or the data received being a multiple that they don't like and those last few bytes don't trigger EOF and the thing timesout instead.

They work great if you make up your own protocal with sizes of packets sent with the data, etc, but trying to use them for web always fails somewhere.  TCP LINE works the best since the headers browsers send end in CRLF I can use something like the following to get the headers:


Do
   Tcp Line #hConnection, sTemp
   sBuffer= sBuffer + sTemp
   If Len(sTemp) And Eof(hConnection) Then Iterate Do 'partial line
   sPacket = sPacket + sBuffer + $CrLf
   ' process sBuffer here or parse outside loop
   Reset sBuffer
Loop Until (Len(sTemp)= 0 And Eof(hConnection)) Or Err


Works ok as long as the last line is empty...if there is a message body, say with a PUT command and Form data sent to it from IE, etc it may loop around 1 more time and timeout.  If I just do until len=0 OR EOF OR Err then it will exit on partial lines, empty lines, and other fun stuff.

Best part is that isn't even the part making things hard.  In IE when you right click and select to Save Target it actually sends the server a GET command instead of HEAD which I also process...so the whole time my app is sending the file and IE sits there saying it is gathering information and doesn't even allow you to select where to save the file till it is all sent.  My Header I return to IE has the file size, date, everything according to specs, but it acts like it doesn't see it.  And, I know for a fact the headers work because IE sends If-Modified lines on refresh with the date of the file I sent it, etc.  I noticed the same thing some time back when PB had a 13MB mp3 of Bob talking on the radio...it would just sit until the full file was downloaded then it would let you save it...maybe they really do use their products even though Microsoft-IIS/5.0 is reported as their server when I connect???

Jose Roca

Beep beep! The Road Runner rides again! :)
Wrapper functions for the Microsoft Winsock Control 6.0 (MSWINSCK.OCX). I only have made a simple test to check that the control initializes and returns the IP address and the local host name. I don't have any experience with Winsock, so you will need to read Microsoft documentation.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/VBRef98/html/vbmscLROverview.asp
Then click Controls reference->ActiveX Controls->Winsock Control


' ********************************************************************************************
' Library name: MSWinsockLib
' Version: 1.0
' Documentation string: Microsoft Winsock Control 6.0
' Path: C:\WINNT\system32\MSWINSCK.OCX
' Library GUID: {248DD890-BB45-11CF-9ABC-0080C7E7B78D}
' Help file: C:\WINNT\HELP\MSWNSK98.chm
' License key: 2C49F800-C2DD-11CF-9AD6-0080C7E7B78D
' ********************************************************************************************

' ********************************************************************************************
' Winsock Control
' ********************************************************************************************
' The Winsock control, invisible to the user, provides easy access to TCP and UDP network
' services. It can be used by Microsoft Access, Visual Basic, Visual C++, or Visual FoxPro
' developers. To write client or server applications you do not need to understand the details
' of TCP or to call low level Winsock APIs. By setting properties and invoking methods of the
' control, you can easily connect to a remote machine and exchange data in both directions.
' TCP Basics
' The Transfer Control Protocol allows you to create and maintain a connection to a remote
' computer. Using the connection, both computers can stream data between themselves.
' If you are creating a client application, you must know the server computer's name or IP
' address (RemoteHost property), as well as the port (RemotePort property) on which it will be
' "listening." Then invoke the Connect method.
' If you are creating a server application, set a port (LocalPort property) on which to listen,
' and invoke the Listen method. When the client computer requests a connection, the
' ConnectionRequest event will occur. To complete the connection, invoke the Accept method
' within the ConnectionRequest event.
' Once a connection has been made, either computer can send and receive data. To send data,
' invoke the SendData method. Whenever data is received, the DataArrival event occurs. Invoke
' the GetData method within the DataArrival event to retrieve the data.
' UDP Basics
' The User Datagram Protocol (UDP) is a connectionless protocol. Unlike TCP operations,
' computers do not establish a connection. Also, a UDP application can be either a client or
' a server.
' To transmit data, first set the client computer's LocalPort property. The server computer
' then needs only to set the RemoteHost to the Internet address of the client computer, and
' the RemotePort property to the same port as the client computer's LocalPort property, and
' invoke the SendData method to begin sending messages. The client computer then uses the
' GetData method within the DataArrival event to retrieve the sent messages.
' ********************************************************************************************



DECLARE FUNCTION CoGetClassObject LIB "OLE32.DLL" ALIAS "CoGetClassObject" (rclsid AS GUID, BYVAL dwclsContext AS DWORD, BYVAL pServerInfo AS DWORD, riid AS GUID, ppv AS DWORD) AS DWORD

' ********************************************************************************************
' ErrorConstants enumeration
' Help context: 340049 (&H00053051)
' Documentation string: Error Constants
' Member identifier: 5
' Number of constants: 37
' ********************************************************************************************

%sckInvalidPropertyValue = 380   ' (&H17C)
%sckGetNotSupported = 394   ' (&H18A)
%sckSetNotSupported = 383   ' (&H17F)
%sckOutOfMemory = 7   ' (&H7)
%sckBadState = 40006   ' (&H9C46)
%sckInvalidArg = 40014   ' (&H9C4E)
%sckSuccess = 40017   ' (&H9C51)
%sckUnsupported = 40018   ' (&H9C52)
%sckInvalidOp = 40020   ' (&H9C54)
%sckOutOfRange = 40021   ' (&H9C55)
%sckWrongProtocol = 40026   ' (&H9C5A)
%sckOpCanceled = 10004   ' (&H2714)
%sckInvalidArgument = 10014   ' (&H271E)
%sckWouldBlock = 10035   ' (&H2733)
%sckInProgress = 10036   ' (&H2734)
%sckAlreadyComplete = 10037   ' (&H2735)
%sckNotSocket = 10038   ' (&H2736)
%sckMsgTooBig = 10040   ' (&H2738)
%sckPortNotSupported = 10043   ' (&H273B)
%sckAddressInUse = 10048   ' (&H2740)
%sckAddressNotAvailable = 10049   ' (&H2741)
%sckNetworkSubsystemFailed = 10050   ' (&H2742)
%sckNetworkUnreachable = 10051   ' (&H2743)
%sckNetReset = 10052   ' (&H2744)
%sckConnectAborted = 10053   ' (&H2745)
%sckConnectionReset = 10054   ' (&H2746)
%sckNoBufferSpace = 10055   ' (&H2747)
%sckAlreadyConnected = 10056   ' (&H2748)
%sckNotConnected = 10057   ' (&H2749)
%sckSocketShutdown = 10058   ' (&H274A)
%sckTimedout = 10060   ' (&H274C)
%sckConnectionRefused = 10061   ' (&H274D)
%sckNotInitialized = 10093   ' (&H276D)
%sckHostNotFound = 11001   ' (&H2AF9)
%sckHostNotFoundTryAgain = 11002   ' (&H2AFA)
%sckNonRecoverableError = 11003   ' (&H2AFB)
%sckNoData = 11004   ' (&H2AFC)

' ********************************************************************************************
' ProtocolConstants enumeration
' Help context: 340047 (&H0005304F)
' Documentation string: Protocol Constants
' Member identifier: 0
' Number of constants: 2
' ********************************************************************************************

%sckTCPProtocol = 0   ' (&H0)
%sckUDPProtocol = 1   ' (&H1)

' ********************************************************************************************
' StateConstants enumeration
' Help context: 340050 (&H00053052)
' Documentation string: State Constants
' Member identifier: 4
' Number of constants: 10
' ********************************************************************************************

%sckClosed = 0   ' (&H0)
%sckOpen = 1   ' (&H1)
%sckListening = 2   ' (&H2)
%sckConnectionPending = 3   ' (&H3)
%sckResolvingHost = 4   ' (&H4)
%sckHostResolved = 5   ' (&H5)
%sckConnecting = 6   ' (&H6)
%sckConnected = 7   ' (&H7)
%sckClosing = 8   ' (&H8)
%sckError = 9   ' (&H9)


' ********************************************************************************************
' Global error variable
' ********************************************************************************************
GLOBAL FF_MSWinsockResult AS DWORD
' ********************************************************************************************

' ********************************************************************************************
' Creates a licensed instance of the Winsock class
' StrProgID can be the ProgID or the ClsID. If you pass a version dependent ProgID or a ClsID,
' it will work only with this particular version. You can pass an empty string and the function
' will use the version independent ProgID, if it has been able to retrieve it, or the ClsID of
' the version you were using when you generated this file.
' ********************************************************************************************
declare FUNCTION MSWinsock_IClassFactory2_CreateInstanceLic ( _
     BYVAL pthis AS DWORD, _
     BYVAL pUnkOuter AS DWORD, _
     BYVAL pUnkReserved AS DWORD, _
     BYREF riid as GUID, _
     BYVAL pbstrKey AS DWORD, _
     BYREF ppvObj AS DWORD _
     ) AS DWORD

FUNCTION NewLicMSWinsock (OPTIONAL BYVAL strLicKey AS STRING, BYVAL strProgID AS STRING, BYVAL lContext AS LONG) EXPORT AS DWORD
   LOCAL ppv AS DWORD, ppvObj AS DWORD, CLSID_Winsock AS GUID, IID_IMSWinsockControl AS GUID, IID_IClassFactory2 AS GUID, pbstrLicKey AS STRING
   IID_IClassFactory2 = GUID$("{b196b28f-bab4-101a-b69c-00aa00341d07}")
   IF ISFALSE lContext THEN lContext = 1  ' %CLSCTX_INPROC_SERVER - Component is allowed in the same process space.
   IF LEN(strProgID) THEN
      IF LEN(GUID$(strProgID)) THEN  ' It is a GUID
         CLSID_Winsock = GUID$(strProgID)
      ELSE
         CLSID_Winsock = CLSID$(strProgID)  ' It is a ProgID
      END IF
   ELSE
      ' Use the retrieved version independent ProgID
      CLSID_Winsock = CLSID$("MSWinsock.Winsock")
   END IF
   IF LEN(strLicKey) THEN pbstrLicKey = UCODE$(strLicKey) ELSE pbstrLicKey = UCODE$("2c49f800-c2dd-11cf-9ad6-0080c7e7b78d")
   FF_MSWinsockResult = CoGetClassObject(CLSID_Winsock, lContext, %NULL, IID_IClassFactory2, ppv)
   IF FF_MSWinsockResult THEN EXIT FUNCTION
   IID_IMSWinsockControl = GUID$("{248DD892-BB45-11CF-9ABC-0080C7E7B78D}")
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = ppv : pvtbl = @ppthis : ppmethod = pvtbl + 28 : pmethod = @ppmethod
   CALL DWORD pmethod USING MSWinsock_IClassFactory2_CreateInstanceLic(ppv, %NULL, %NULL, IID_IMSWinsockControl, STRPTR(pbstrLicKey), ppvObj) TO FF_MSWinsockResult
   FUNCTION = ppvObj
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Decrements the reference count for the calling interface on a object. If the reference count
' on the object falls to 0, the object is freed from memory.
' Return Value:
' Returns the resulting value of the reference count, which is used for diagnostic/testing
' purposes only.
' ********************************************************************************************
FUNCTION FF_MSWinsock_Release (BYVAL pthis AS DWORD) AS DWORD

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD, hr AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 8 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_Release(pthis) TO hr
   FUNCTION = hr

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' IMSWinsockControl interface
' Help context: 340024 (&H00053038)
' Documentation string: Winsock methods and events
' IID: {248DD892-BB45-11CF-9ABC-0080C7E7B78D}
' Interface flags: &H10D0 [Hidden] [Dual] [Nonextensible] [Dispatchable]
' Member identifier: 1
' Number of functions: 32
' ********************************************************************************************

' ********************************************************************************************
' AboutBox method  [Hidden]
' Interface name: IMSWinsockControl
' VTable offset: 28
' Member identifier: -552
' ********************************************************************************************
FUNCTION FF_MSWinsock_AboutBox ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 28 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_AboutBox(pthis) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]Protocol property
' Interface name: IMSWinsockControl
' Help context: 340031 (&H0005303F)
' Documentation string: Returns the socket protocol
' VTable offset: 32
' Member identifier: 3
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_GetProtocol ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS LONG _                                    ' [OUT] ProtocolConstants
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_GetProtocol ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS LONG                                           ' ProtocolConstants

   DIM pRetVal AS LONG, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 32 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_GetProtocol(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = pRetVal

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]Protocol property
' Interface name: IMSWinsockControl
' Help context: 340031 (&H0005303F)
' Documentation string: Sets the socket protocol
' VTable offset: 36
' Member identifier: 3
' ********************************************************************************************
FUNCTION FF_MSWinsock_SetProtocol ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYVAL prmProtocol AS LONG _                                ' [IN] <ProtocolConstants>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 36 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_SetProtocol(pthis, prmProtocol) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]RemoteHostIP property
' Interface name: IMSWinsockControl
' Help context: 340025 (&H00053039)
' Documentation string: Returns the remote host IP address
' VTable offset: 40
' Member identifier: 4
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_GetRemoteHostIP ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS STRING _                                  ' [OUT] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_GetRemoteHostIP ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS STRING                                         ' VT_BSTR <DYNAMIC UNICODE STRING>

   DIM pRetVal AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 40 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_GetRemoteHostIP(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = ACODE$(pRetVal)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]LocalHostName property
' Interface name: IMSWinsockControl
' Help context: 340026 (&H0005303A)
' Documentation string: Returns the local machine name
' VTable offset: 44
' Member identifier: 5
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_GetLocalHostName ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS STRING _                                  ' [OUT] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_GetLocalHostName ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS STRING                                         ' VT_BSTR <DYNAMIC UNICODE STRING>

   DIM pRetVal AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 44 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_GetLocalHostName(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = ACODE$(pRetVal)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]LocalIP property
' Interface name: IMSWinsockControl
' Help context: 340027 (&H0005303B)
' Documentation string: Returns the local machine IP address
' VTable offset: 48
' Member identifier: 6
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_GetLocalIP ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS STRING _                                  ' [OUT] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_GetLocalIP ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS STRING                                         ' VT_BSTR <DYNAMIC UNICODE STRING>

   DIM pRetVal AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 48 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_GetLocalIP(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = ACODE$(pRetVal)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]SocketHandle property
' Interface name: IMSWinsockControl
' Help context: 340028 (&H0005303C)
' Documentation string: Returns the socket handle
' VTable offset: 52
' Member identifier: 7
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_GetSocketHandle ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS LONG _                                    ' [OUT] VT_I4 <LONG>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_GetSocketHandle ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS LONG                                           ' VT_I4 <LONG>

   DIM pRetVal AS LONG, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 52 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_GetSocketHandle(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = pRetVal

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]_RemoteHost property  [Hidden]
' Interface name: IMSWinsockControl
' VTable offset: 56
' Member identifier: 0
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_Get_RemoteHost ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS STRING _                                  ' [OUT] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_Get_RemoteHost ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS STRING                                         ' VT_BSTR <DYNAMIC UNICODE STRING>

   DIM pRetVal AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 56 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_Get_RemoteHost(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = ACODE$(pRetVal)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]_RemoteHost property  [Hidden]
' Interface name: IMSWinsockControl
' VTable offset: 60
' Member identifier: 0
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_Set_RemoteHost ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYVAL pbstr_RemoteHost AS DWORD _                          ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_Set_RemoteHost ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYVAL pbstr_RemoteHost AS STRING _                         ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   pbstr_RemoteHost = UCODE$(pbstr_RemoteHost)
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 60 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_Set_RemoteHost(pthis, STRPTR(pbstr_RemoteHost)) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]RemotePort property
' Interface name: IMSWinsockControl
' Help context: 340012 (&H0005302C)
' Documentation string: Returns the port to be connected to on the remote computer
' VTable offset: 64
' Member identifier: 1
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_GetRemotePort ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS LONG _                                    ' [OUT] VT_I4 <LONG>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_GetRemotePort ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS LONG                                           ' VT_I4 <LONG>

   DIM pRetVal AS LONG, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 64 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_GetRemotePort(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = pRetVal

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]RemotePort property
' Interface name: IMSWinsockControl
' Help context: 340012 (&H0005302C)
' Documentation string: Sets the port to be connected to on the remote computer
' VTable offset: 68
' Member identifier: 1
' ********************************************************************************************
FUNCTION FF_MSWinsock_SetRemotePort ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYVAL prmRemotePort AS LONG _                              ' [IN] VT_I4 <LONG>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 68 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_SetRemotePort(pthis, prmRemotePort) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]LocalPort property
' Interface name: IMSWinsockControl
' Help context: 340013 (&H0005302D)
' Documentation string: Returns the port used on the local computer
' VTable offset: 72
' Member identifier: 2
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_GetLocalPort ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS LONG _                                    ' [OUT] VT_I4 <LONG>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_GetLocalPort ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS LONG                                           ' VT_I4 <LONG>

   DIM pRetVal AS LONG, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 72 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_GetLocalPort(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = pRetVal

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]LocalPort property
' Interface name: IMSWinsockControl
' Help context: 340013 (&H0005302D)
' Documentation string: Sets the port used on the local computer
' VTable offset: 76
' Member identifier: 2
' ********************************************************************************************
FUNCTION FF_MSWinsock_SetLocalPort ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYVAL prmLocalPort AS LONG _                               ' [IN] VT_I4 <LONG>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 76 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_SetLocalPort(pthis, prmLocalPort) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]State property
' Interface name: IMSWinsockControl
' Help context: 340014 (&H0005302E)
' Documentation string: Returns the state of the socket connection
' VTable offset: 80
' Member identifier: 8
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_GetState ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS INTEGER _                                 ' [OUT] VT_I2 <INTEGER>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_GetState ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS INTEGER                                        ' VT_I2 <INTEGER>

   DIM pRetVal AS INTEGER, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 80 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_GetState(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = pRetVal

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]BytesReceived property
' Interface name: IMSWinsockControl
' Help context: 340015 (&H0005302F)
' Documentation string: Returns the number of bytes received on this connection
' VTable offset: 84
' Member identifier: 9
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_GetBytesReceived ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS LONG _                                    ' [OUT] VT_I4 <LONG>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_GetBytesReceived ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS LONG                                           ' VT_I4 <LONG>

   DIM pRetVal AS LONG, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 84 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_GetBytesReceived(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = pRetVal

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Connect method
' Interface name: IMSWinsockControl
' Help context: 340016 (&H00053030)
' Documentation string: Connect to the remote computer
' VTable offset: 88
' Member identifier: 64
' ********************************************************************************************
FUNCTION FF_MSWinsock_Connect ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   OPTIONAL BYVAL RemoteHost AS VARIANT, _                    ' [IN] [OPT] VT_VARIANT <VARIANT>
   OPTIONAL BYVAL RemotePort AS VARIANT _                     ' [IN] [OPT] VT_VARIANT <VARIANT>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   IF VARIANTVT(RemoteHost) = %VT_EMPTY THEN RemoteHost  = ERROR %DISP_E_PARAMNOTFOUND
   IF VARIANTVT(RemotePort) = %VT_EMPTY THEN RemotePort  = ERROR %DISP_E_PARAMNOTFOUND
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 88 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_Connect(pthis, RemoteHost, RemotePort) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Listen method
' Interface name: IMSWinsockControl
' Help context: 340017 (&H00053031)
' Documentation string: Listen for incoming connection requests
' VTable offset: 92
' Member identifier: 65
' ********************************************************************************************
FUNCTION FF_MSWinsock_Listen ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 92 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_Listen(pthis) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Accept method
' Interface name: IMSWinsockControl
' Help context: 340018 (&H00053032)
' Documentation string: Accept an incoming connection request
' VTable offset: 96
' Member identifier: 66
' ********************************************************************************************
FUNCTION FF_MSWinsock_Accept ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYVAL requestID AS LONG _                                  ' [IN] VT_I4 <LONG>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 96 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_Accept(pthis, requestID) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' SendData method
' Interface name: IMSWinsockControl
' Help context: 340019 (&H00053033)
' Documentation string: Send data to remote computer
' VTable offset: 100
' Member identifier: 67
' ********************************************************************************************
FUNCTION FF_MSWinsock_SendData ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYVAL vardata AS VARIANT _                                 ' [IN] VT_VARIANT <VARIANT>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 100 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_SendData(pthis, vardata) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' GetData method
' Interface name: IMSWinsockControl
' Help context: 340020 (&H00053034)
' Documentation string: Retrieve data sent by the remote computer
' VTable offset: 104
' Member identifier: 68
' ********************************************************************************************
FUNCTION FF_MSWinsock_GetData ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF prmdata AS VARIANT, _                                ' [IN] [OUT] <*VT_VARIANT <VARIANT>>
   OPTIONAL BYVAL varPrmtype AS VARIANT, _                    ' [IN] [OPT] VT_VARIANT <VARIANT>
   OPTIONAL BYVAL maxLen AS VARIANT _                         ' [IN] [OPT] VT_VARIANT <VARIANT>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   IF VARIANTVT(varPrmtype) = %VT_EMPTY THEN varPrmtype  = ERROR %DISP_E_PARAMNOTFOUND
   IF VARIANTVT(maxLen) = %VT_EMPTY THEN maxLen  = ERROR %DISP_E_PARAMNOTFOUND
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 104 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_GetData(pthis, prmdata, varPrmtype, maxLen) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' PeekData method
' Interface name: IMSWinsockControl
' Help context: 340021 (&H00053035)
' Documentation string: Look at incoming data without removing it from the buffer
' VTable offset: 108
' Member identifier: 69
' ********************************************************************************************
FUNCTION FF_MSWinsock_PeekData ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF prmdata AS VARIANT, _                                ' [IN] [OUT] <*VT_VARIANT <VARIANT>>
   OPTIONAL BYVAL varPrmtype AS VARIANT, _                    ' [IN] [OPT] VT_VARIANT <VARIANT>
   OPTIONAL BYVAL maxLen AS VARIANT _                         ' [IN] [OPT] VT_VARIANT <VARIANT>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   IF VARIANTVT(varPrmtype) = %VT_EMPTY THEN varPrmtype  = ERROR %DISP_E_PARAMNOTFOUND
   IF VARIANTVT(maxLen) = %VT_EMPTY THEN maxLen  = ERROR %DISP_E_PARAMNOTFOUND
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 108 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_PeekData(pthis, prmdata, varPrmtype, maxLen) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Close method
' Interface name: IMSWinsockControl
' Help context: 340022 (&H00053036)
' Documentation string: Close current connection
' VTable offset: 112
' Member identifier: 70
' ********************************************************************************************
FUNCTION FF_MSWinsock_Close ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 112 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_Close(pthis) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Bind method
' Interface name: IMSWinsockControl
' Help context: 340048 (&H00053050)
' Documentation string: Binds socket to specific port and adapter
' VTable offset: 116
' Member identifier: 71
' ********************************************************************************************
FUNCTION FF_MSWinsock_Bind ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   OPTIONAL BYVAL LocalPort AS VARIANT, _                     ' [IN] [OPT] VT_VARIANT <VARIANT>
   OPTIONAL BYVAL LocalIP AS VARIANT _                        ' [IN] [OPT] VT_VARIANT <VARIANT>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   IF VARIANTVT(LocalPort) = %VT_EMPTY THEN LocalPort  = ERROR %DISP_E_PARAMNOTFOUND
   IF VARIANTVT(LocalIP) = %VT_EMPTY THEN LocalIP  = ERROR %DISP_E_PARAMNOTFOUND
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 116 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSWinsock_Bind(pthis, LocalPort, LocalIP) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]RemoteHost property
' Interface name: IMSWinsockControl
' Help context: 340011 (&H0005302B)
' Documentation string: Returns the name used to identify the remote computer
' VTable offset: 120
' Member identifier: 10
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_GetRemoteHost ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYREF pRetVal AS STRING _                                  ' [OUT] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_GetRemoteHost ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <VT_IUNKNOWN>
   ) EXPORT AS STRING                                         ' VT_BSTR <DYNAMIC UNICODE STRING>

   DIM pRetVal AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 120 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_GetRemoteHost(pthis, pRetVal) TO FF_MSWinsockResult
   FUNCTION = ACODE$(pRetVal)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]RemoteHost property
' Interface name: IMSWinsockControl
' Help context: 340011 (&H0005302B)
' Documentation string: Sets the name used to identify the remote computer
' VTable offset: 124
' Member identifier: 10
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSWinsock_SetRemoteHost ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYVAL pbstrRemoteHost AS DWORD _                           ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSWinsock_SetRemoteHost ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <VT_IUNKNOWN>
   BYVAL pbstrRemoteHost AS STRING _                          ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) EXPORT AS DWORD                                          ' VT_HRESULT <DWORD>

   pbstrRemoteHost = UCODE$(pbstrRemoteHost)
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 124 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSWinsock_SetRemoteHost(pthis, STRPTR(pbstrRemoteHost)) TO FF_MSWinsockResult
   FUNCTION = FF_MSWinsockResult

END FUNCTION
' ********************************************************************************************


function pbmain

  local lpWinsock as dword

  ' Create a licensed instance of the Winsock object
  lpWinsock = NewLicMSWinsock
  if isfalse lpWinsock then exit function
 
  ' Retrieve the LocalIP property
  msgbox FF_MSWinsock_GetLocalIP(lpWinsock)
  msgbox FF_MSWinsock_GetLocalHostName(lpWinsock)

  ' Release the interface
  if lpWinsock then FF_MSWinsock_Release lpWinsock

end function

Jose Roca

Sorry, forgot to post the code for events.


' ********************************************************************************************
' OnEvent Functions
' ********************************************************************************************
' Variants can hold any kind of numeric values. When returning one of these values you can
' assign them directly, e.g. #pvapi[1].vd.@plVal = -1, but when you need to assign an string
' or a variant you need to declare a variable of the appropiate kind and pass his address with
' VARPTR. Strings must be converted to unicode with UCODE$. You have to manipulate the variant
' using pointers because when you assign a value to a byref variant with PB, the variant loses
' his byref flag and PB doesn't provide a way to set it.
' ********************************************************************************************



' ********************************************************************************************
' DMSWinsockControlEvents dispatch interface
' Help context: 340029 (&H0005303D)
' Documentation string: Microsoft Winsock Control events
' GUID: {248DD893-BB45-11CF-9ABC-0080C7E7B78D}
' Member identifier: 2
' Number of functions: 7
' ********************************************************************************************

' ********************************************************************************************
' Builds the IDispatch Virtual Table
' ********************************************************************************************
SUB FF_MSWinsockControlEvents_BuildVtbl (Vtbl AS TB_IDispatchVtbl)
  VTbl.QueryInterface   = CODEPTR(FF_MSWinsockControlEvents_QueryInterface)
  VTbl.AddRef           = CODEPTR(FF_MSWinsockControlEvents_AddRef)
  VTbl.Release          = CODEPTR(FF_MSWinsockControlEvents_Release)
  VTbl.GetTypeInfoCount = CODEPTR(FF_MSWinsockControlEvents_GetTypeInfoCount)
  VTbl.GetTypeInfo      = CODEPTR(FF_MSWinsockControlEvents_GetTypeInfo)
  VTbl.GetIDsOfNames    = CODEPTR(FF_MSWinsockControlEvents_GetIDsOfNames)
  VTbl.Invoke           = CODEPTR(FF_MSWinsockControlEvents_Invoke)
END SUB
' ********************************************************************************************

' ********************************************************************************************
' HRESULT QueryInterface([in] *GUID riid, [out] **VOID ppvObj)
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_QueryInterface (BYVAL pthis AS DWORD, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS DWORD
  STATIC pSink AS DWORD, Vtbl AS TB_IDispatchVtbl
  FF_MSWinsockControlEvents_BuildVtbl(Vtbl)
  pSink = VARPTR(Vtbl)
  ppvObj = VARPTR(pSink)
  FUNCTION = 0 ' %S_OK
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' UI4 AddRef()
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_AddRef (BYVAL pthis AS DWORD) AS DWORD
  FUNCTION = 1
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' UI4 Release()
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_Release (BYVAL pthis AS DWORD) AS DWORD
  FUNCTION = 1
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' HRESULT GetTypeInfoCount([out] *UINT pctinfo)
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_GetTypeInfoCount (BYVAL pthis AS DWORD, BYREF pctInfo AS DWORD) AS DWORD
  FUNCTION = &H80004001 ' %E_NOTIMPL
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' HRESULT GetTypeInfo([in] UINT itinfo, [in] UI4 lcid, [out] **VOID pptinfo)
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_GetTypeInfo (BYVAL pthis AS DWORD, BYVAL itinfo AS DWORD, BYVAL lcid AS DWORD, BYREF pptinfo AS DWORD) AS DWORD
  FUNCTION = &H80004001 ' %E_NOTIMPL
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' HRESULT GetIDsOfNames([in] *GUID riid, [in] **I1 rgszNames, [in] UINT cNames, [in] UI4 lcid, [out] *I4 rgdispid)
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_GetIDsOfNames (BYVAL pthis AS DWORD, BYREF riid AS GUID, BYVAL rgszNames AS DWORD, BYVAL cNames AS DWORD, BYVAL lcid AS DWORD, BYREF rgdispid AS LONG) AS DWORD
  FUNCTION = &H80004001 ' %E_NOTIMPL
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Establishes a connection between the connection point object and the client's sink.
' Returns a token that uniquely identifies this connection.
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_SetEvents (BYVAL pthis AS DWORD, BYREF pdwCookie AS DWORD) AS DWORD

  LOCAL HRESULT AS DWORD                ' HRESULT code
  LOCAL pCPC AS DWORD                   ' IConnectionPointContainer
  LOCAL pCP AS DWORD                    ' IConnectionPoint
  LOCAL IID_CPC AS GUID                 ' IID_IConnectionPointContainer
  LOCAL IID_CP AS GUID                  ' Events dispinterface
  LOCAL pSink AS DWORD                  ' Pointer to our sink interface
  LOCAL dwCookie AS DWORD               ' Returned token
  STATIC Vtbl AS TB_IDispatchVtbl       ' Vtbl structure

  IID_CPC = GUID$("{B196B284-BAB4-101A-B69C-00AA00341D07}")
  IID_CP  = GUID$("{248DD893-BB45-11CF-9ABC-0080C7E7B78D}")

  HRESULT = IUnknown_QueryInterface(pthis, IID_CPC, pCPC)
  IF HRESULT <> 0 THEN FUNCTION = HRESULT : EXIT FUNCTION

  HRESULT = IConnectionPointContainer_FindConnectionPoint(pCPC, IID_CP, pCP)
  IUnknown_Release pCPC
  IF HRESULT <> 0 THEN FUNCTION = HRESULT : EXIT FUNCTION

  FF_MSWinsockControlEvents_BuildVtbl(Vtbl)
  pSink = VARPTR(Vtbl)
  HRESULT = IConnectionPoint_Advise(pCP, BYVAL VARPTR(pSink), dwCookie)

  pdwCookie = dwCookie
  IUnknown_Release pCP
  FUNCTION = HRESULT

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Releases the events connection identified with the cookie returned by the SetEvents function
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_ReleaseEvents (BYVAL pthis AS DWORD, BYVAL dwCookie AS DWORD) AS DWORD

  LOCAL HRESULT AS DWORD                ' HRESULT code
  LOCAL pCPC AS DWORD                   ' IConnectionPointContainer
  LOCAL pCP AS DWORD                    ' IConnectionPoint
  LOCAL IID_CPC AS GUID                 ' IID_IConnectionPointContainer
  LOCAL IID_CP AS GUID                  ' ConnectionEvents dispinterface

  IID_CPC = GUID$("{B196B284-BAB4-101A-B69C-00AA00341D07}")
  IID_CP  = GUID$("{248DD893-BB45-11CF-9ABC-0080C7E7B78D}")

  HRESULT = Iunknown_QueryInterface(pthis, IID_CPC, pCPC)
  IF HRESULT <> 0 THEN FUNCTION = HRESULT : EXIT FUNCTION

  HRESULT = IConnectionPointContainer_FindConnectionPoint(pCPC, IID_CP, pCP)
  IUnknown_Release pCPC
  IF HRESULT <> 0 THEN FUNCTION = HRESULT : EXIT FUNCTION

  HRESULT = IConnectionPoint_Unadvise(pCP, dwCookie)
  IUnknown_Release pCP
  FUNCTION = HRESULT

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Function name: Error
' Dispatch interface name: DMSWinsockControlEvents
' Help context: 340040 (&H00053048)
' Documentation string: Error occurred
' Member identifier: 6
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_Error (BYVAL dwCookie AS DWORD, BYREF pdispparams AS DISPPARAMS) AS DWORD
  LOCAL pv AS VARIANT PTR, pvapi AS VARIANTAPITYPE PTR
  pv = pdispparams.VariantArgs : pvapi = pv
'  ==============================================================================
'  Parameters in DISPPARAMS are zero based and in reverse order
'  ==============================================================================
  LOCAL Number AS INTEGER
  Number = VARIANT#(@pv[6])
  STATIC Description AS STRING
  Description = VARIANT$(@pv[5])
  ' To return a value, use:
  ' Description = UCODE$(<value>) : @pvapi[5].vd.@pbstrval = STRPTR(Description)
  LOCAL Scode AS LONG
  Scode = VARIANT#(@pv[4])
  LOCAL Source AS STRING
  Source = VARIANT$(@pv[3])
  LOCAL HelpFile AS STRING
  HelpFile = VARIANT$(@pv[2])
  LOCAL HelpContext AS LONG
  HelpContext = VARIANT#(@pv[1])
  STATIC CancelDisplay AS INTEGER
  CancelDisplay = VARIANT#(@pv[0])
  ' To return a value, use:
  ' CancelDisplay = <value> : @pvapi[0].vd.@pboolVal = CancelDisplay
'  ==============================================================================
'  *** Put your code here ***
'  ==============================================================================
  FUNCTION = 0 ' %S_OK
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Function name: DataArrival
' Dispatch interface name: DMSWinsockControlEvents
' Help context: 340041 (&H00053049)
' Documentation string: Occurs when data has been received from the remote computer
' Member identifier: 0
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_DataArrival (BYVAL dwCookie AS DWORD, BYREF pdispparams AS DISPPARAMS) AS DWORD
  LOCAL pv AS VARIANT PTR, pvapi AS VARIANTAPITYPE PTR
  pv = pdispparams.VariantArgs : pvapi = pv
'  ==============================================================================
'  Parameters in DISPPARAMS are zero based and in reverse order
'  ==============================================================================
  LOCAL bytesTotal AS LONG
  bytesTotal = VARIANT#(@pv[0])
'  ==============================================================================
'  *** Put your code here ***
'  ==============================================================================
  FUNCTION = 0 ' %S_OK
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Function name: Connect
' Dispatch interface name: DMSWinsockControlEvents
' Help context: 340042 (&H0005304A)
' Documentation string: Occurs connect operation is completed
' Member identifier: 1
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_Connect (BYVAL dwCookie AS DWORD, BYREF pdispparams AS DISPPARAMS) AS DWORD
  FUNCTION = 0 ' %S_OK
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Function name: ConnectionRequest
' Dispatch interface name: DMSWinsockControlEvents
' Help context: 340043 (&H0005304B)
' Documentation string: Occurs when a remote client is attempting to connect
' Member identifier: 2
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_ConnectionRequest (BYVAL dwCookie AS DWORD, BYREF pdispparams AS DISPPARAMS) AS DWORD
  LOCAL pv AS VARIANT PTR, pvapi AS VARIANTAPITYPE PTR
  pv = pdispparams.VariantArgs : pvapi = pv
'  ==============================================================================
'  Parameters in DISPPARAMS are zero based and in reverse order
'  ==============================================================================
  LOCAL requestID AS LONG
  requestID = VARIANT#(@pv[0])
'  ==============================================================================
'  *** Put your code here ***
'  ==============================================================================
  FUNCTION = 0 ' %S_OK
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Function name: Close
' Dispatch interface name: DMSWinsockControlEvents
' Help context: 340044 (&H0005304C)
' Documentation string: Occurs when the connection has been closed
' Member identifier: 5
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_Close (BYVAL dwCookie AS DWORD, BYREF pdispparams AS DISPPARAMS) AS DWORD
  FUNCTION = 0 ' %S_OK
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Function name: SendProgress
' Dispatch interface name: DMSWinsockControlEvents
' Help context: 340045 (&H0005304D)
' Documentation string: Occurs during process of sending data
' Member identifier: 3
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_SendProgress (BYVAL dwCookie AS DWORD, BYREF pdispparams AS DISPPARAMS) AS DWORD
  LOCAL pv AS VARIANT PTR, pvapi AS VARIANTAPITYPE PTR
  pv = pdispparams.VariantArgs : pvapi = pv
'  ==============================================================================
'  Parameters in DISPPARAMS are zero based and in reverse order
'  ==============================================================================
  LOCAL bytesSent AS LONG
  bytesSent = VARIANT#(@pv[1])
  LOCAL bytesRemaining AS LONG
  bytesRemaining = VARIANT#(@pv[0])
'  ==============================================================================
'  *** Put your code here ***
'  ==============================================================================
  FUNCTION = 0 ' %S_OK
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Function name: SendComplete
' Dispatch interface name: DMSWinsockControlEvents
' Help context: 340046 (&H0005304E)
' Documentation string: Occurs after a send operation has completed
' Member identifier: 4
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_SendComplete (BYVAL dwCookie AS DWORD, BYREF pdispparams AS DISPPARAMS) AS DWORD
  FUNCTION = 0 ' %S_OK
END FUNCTION
' ********************************************************************************************


' ********************************************************************************************
' HRESULT Invoke([in] I4 dispidMember, [in] *GUID riid, [in] UI4 lcid, [in] UI2 wFlags, [in] *DISPPARAMS pdispparams, [out] *VARIANT pvarResult, [out] *EXCEPINFO pexcepinfo, [out] *UINT puArgErr)
' ********************************************************************************************
FUNCTION FF_MSWinsockControlEvents_Invoke (BYVAL dwCookie AS DWORD, BYVAL dispidMember AS LONG, BYREF riid AS GUID, _
 BYVAL lcid AS DWORD, BYVAL wFlags AS WORD, BYREF pdispparams AS DISPPARAMS, BYREF pvarResult AS VARIANT, _
 BYREF pexcepinfo AS EXCEPINFO, BYREF puArgErr AS DWORD) AS DWORD

  FUNCTION = 0 ' %S_OK
  IF VARPTR(pdispparams) THEN

     SELECT CASE AS LONG dispidMember
        CASE &H6  ' (6)  ' // Error
           FUNCTION = FF_MSWinsockControlEvents_Error(dwCookie, pdispparams)
        CASE &H0  ' (0)  ' // DataArrival
           FUNCTION = FF_MSWinsockControlEvents_DataArrival(dwCookie, pdispparams)
        CASE &H1  ' (1)  ' // Connect
           FUNCTION = FF_MSWinsockControlEvents_Connect(dwCookie, pdispparams)
        CASE &H2  ' (2)  ' // ConnectionRequest
           FUNCTION = FF_MSWinsockControlEvents_ConnectionRequest(dwCookie, pdispparams)
        CASE &H5  ' (5)  ' // Close
           FUNCTION = FF_MSWinsockControlEvents_Close(dwCookie, pdispparams)
        CASE &H3  ' (3)  ' // SendProgress
           FUNCTION = FF_MSWinsockControlEvents_SendProgress(dwCookie, pdispparams)
        CASE &H4  ' (4)  ' // SendComplete
           FUNCTION = FF_MSWinsockControlEvents_SendComplete(dwCookie, pdispparams)

     END SELECT
  END IF

END FUNCTION
' ********************************************************************************************

Jose Roca

Beep beep! Wrapper functions for MSINET.OCX (Microsoft Internet Transfer Control).

[code]
' ********************************************************************************************
' Library name: InetCtlsObjects
' Version: 1.0
' Documentation string: Microsoft Internet Transfer Control 6.0
' Path: C:\WINNT\system32\MSINET.OCX
' Library GUID: {48E59290-9880-11CF-9754-00AA00C00908}
' Help file: C:\WINNT\HELP\INET98.CHM
' License key: 78E1BDD1-9941-11cf-9756-00AA00C00908
' ********************************************************************************************





DECLARE FUNCTION CoGetClassObject LIB "OLE32.DLL" ALIAS "CoGetClassObject" (rclsid AS GUID, BYVAL dwclsContext AS DWORD, BYVAL pServerInfo AS DWORD, riid AS GUID, ppv AS DWORD) AS DWORD

' ********************************************************************************************
' CoClasses
' ********************************************************************************************

' Name: Inet
' CLSID: {48E59293-9880-11CF-9754-00AA00C00908}
' Documentation string: Microsoft Internet Transfer Control
' ProgId: InetCtls.Inet.1
' Version independent ProgID = InetCtls.Inet
' InprocServer32 = C:\WINNT\system32\MSINET.OCX
' Default interface = IInet
' Default events interface = DInetEvents

' ********************************************************************************************
' AccessConstants enumeration
' Help context: 350015 (&H0005573F)
' Documentation string: Access Types
' Member identifier: 1
' Number of constants: 3
' ********************************************************************************************

%icUseDefault = 0   ' (&H0)  ' Default. Use Defaults. The control uses default settings found in the registry to access the Internet.
%icDirect = 1   ' (&H1)      ' Direct to Internet. The control has a direct connection to the Internet.
%icNamedProxy = 2   ' (&H2)  ' Named Proxy. Instructs the control to use the proxy server specified in the Proxy property.

' ********************************************************************************************
' DataTypeConstants enumeration
' Help context: 350061 (&H0005576D)
' Documentation string: Data Types for retrieved data
' Member identifier: 3
' Number of constants: 2
' ********************************************************************************************

%icString = 0   ' (&H0)     ' Default. Retrieves data as string.
%icByteArray = 1   ' (&H1)  ' Retrieves data as a byte array.

' ********************************************************************************************
' ErrorConstants enumeration
' Help context: 350065 (&H00055771)
' Documentation string: Error Constants
' Member identifier: 4
' Number of constants: 102
' ********************************************************************************************

%icOutOfMemory = 7   ' (&H7)
%icTypeMismatch = 13   ' (&HD)
%icInvalidPropertyValue = 380   ' (&H17C)
%icInetOpenFailed = 35750   ' (&H8BA6)
%icUrlOpenFailed = 35751   ' (&H8BA7)
%icBadUrl = 35752   ' (&H8BA8)
%icProtMismatch = 35753   ' (&H8BA9)
%icConnectFailed = 35754   ' (&H8BAA)
%icNoRemoteHost = 35755   ' (&H8BAB)
%icRequestFailed = 35756   ' (&H8BAC)
%icNoExecute = 35757   ' (&H8BAD)
%icBlewChunk = 35758   ' (&H8BAE)
%icFtpCommandFailed = 35759   ' (&H8BAF)
%icUnsupportedType = 35760   ' (&H8BB0)
%icTimeout = 35761   ' (&H8BB1)
%icUnsupportedCommand = 35762   ' (&H8BB2)
%icInvalidOperation = 35763   ' (&H8BB3)
%icExecuting = 35764   ' (&H8BB4)
%icInvalidForFtp = 35765   ' (&H8BB5)
%icOutOfHandles = 35767   ' (&H8BB7)
%icInetTimeout = 35768   ' (&H8BB8)
%icExtendedError = 35769   ' (&H8BB9)
%icIntervalError = 35770   ' (&H8BBA)
%icInvalidURL = 35771   ' (&H8BBB)
%icUnrecognizedScheme = 35772   ' (&H8BBC)
%icNameNotResolved = 35773   ' (&H8BBD)
%icProtocolNotFound = 35774   ' (&H8BBE)
%icInvalidOption = 35775   ' (&H8BBF)
%icBadOptionLength = 35776   ' (&H8BC0)
%icOptionNotSettable = 35777   ' (&H8BC1)
%icShutDown = 35778   ' (&H8BC2)
%icIncorrectUserName = 35779   ' (&H8BC3)
%icIncorrectPassword = 35780   ' (&H8BC4)
%icLoginFailure = 35781   ' (&H8BC5)
%icInetInvalidOperation = 35782   ' (&H8BC6)
%icOperationCancelled = 35783   ' (&H8BC7)
%icIncorrectHandleType = 35784   ' (&H8BC8)
%icIncorrectHandleState = 35785   ' (&H8BC9)
%icNotProxyRequest = 35786   ' (&H8BCA)
%icRegistryValueNotFound = 35787   ' (&H8BCB)
%icBadRegistryParameter = 35788   ' (&H8BCC)
%icNoDirectAccess = 35789   ' (&H8BCD)
%icNoContext = 35790   ' (&H8BCE)
%icNoCallback = 35791   ' (&H8BCF)
%icRequestPending = 35792   ' (&H8BD0)
%icIncorrectFormat = 35793   ' (&H8BD1)
%icItemNotFound = 35794   ' (&H8BD2)
%icCannotConnect = 35795   ' (&H8BD3)
%icConnectionAborted = 35796   ' (&H8BD4)
%icConnectionReset = 35797   ' (&H8BD5)
%icForceRetry = 35798   ' (&H8BD6)
%icInvalidProxyRequest = 35799   ' (&H8BD7)
%icWouldBlock = 35800   ' (&H8BD8)
%icHandleExists = 35802   ' (&H8BDA)
%icSecCertDateInvalid = 35803   ' (&H8BDB)
%icSecCertCnInvalid = 35804   ' (&H8BDC)
%icHttpToHttpsOnRedir = 35805   ' (&H8BDD)
%icHttpsToHttpOnRedir = 35806   ' (&H8BDE)
%icMixedSecurity = 35807   ' (&H8BDF)
%icChgPostIsNonSecure = 35808   ' (&H8BE0)
%icPostIsNonSecure = 35809   ' (&H8BE1)
%icClientAuthCertNeeded = 35810   ' (&H8BE2)
%icInvalidCa = 35811   ' (&H8BE3)
%icClientAuthNotSetup = 35812   ' (&H8BE4)
%icAsyncThreadFailed = 35813   ' (&H8BE5)
%icRedirectSchemeChange = 35814   ' (&H8BE6)
%icDialogPending = 35815   ' (&H8BE7)
%icRetryDialog = 35816   ' (&H8BE8)
%icHttpsHttpSubmitRedir = 35818   ' (&H8BEA)
%icInsertCdrom = 35819   ' (&H8BEB)
%icFtpTransferInProgress = 35876   ' (&H8C24)
%icFtpDropped = 35877   ' (&H8C25)
%icFtpNoPassiveMode = 35878   ' (&H8C26)
%icGopherProtocolError = 35896   ' (&H8C38)
%icGopherNotFile = 35897   ' (&H8C39)
%icGopherDataError = 35898   ' (&H8C3A)
%icGopherEndOfData = 35899   ' (&H8C3B)
%icGopherInvalidLocator = 35900   ' (&H8C3C)
%icGopherIncorrectLocatorType = 35901   ' (&H8C3D)
%icGopherNotGopherPlus = 35902   ' (&H8C3E)
%icGopherAttributeNotFound = 35903   ' (&H8C3F)
%icGopherUnknownLocator = 35904   ' (&H8C40)
%icHttpHeaderNotFound = 35916   ' (&H8C4C)
%icHttpDownlevelServer = 35917   ' (&H8C4D)
%icHttpInvalidServerResponse = 35918   ' (&H8C4E)
%icHttpInvalidHeader = 35919   ' (&H8C4F)
%icHttpInvalidQueryRequest = 35920   ' (&H8C50)
%icHttpHeaderAlreadyExists = 35921   ' (&H8C51)
%icHttpRedirectFailed = 35922   ' (&H8C52)
%icHttpCookieNeedsConfirmation = 35927   ' (&H8C57)
%icHttpCookieDeclined = 35928   ' (&H8C58)
%icHttpRedirectNeedsConfirmation = 35934   ' (&H8C5E)
%icSecurityChannelError = 35923   ' (&H8C53)
%icUnableToCacheFile = 35924   ' (&H8C54)
%icInternetDisconnected = 35929   ' (&H8C59)
%icServerUnreachable = 35930   ' (&H8C5A)
%icProxyServerUnreachable = 35931   ' (&H8C5B)
%icBadAutoProxyScript = 35932   ' (&H8C5C)
%icUnableToDownloadScript = 35933   ' (&H8C5D)
%icSecInvalidCert = 35935   ' (&H8C5F)
%icSecCertRevoked = 35936   ' (&H8C60)
%icFailedDueToSecurityCheck = 35937   ' (&H8C61)

' ********************************************************************************************
' ProtocolConstants enumeration
' Help context: 3500046 (&H0035680E)
' Documentation string: Protocols
' Member identifier: 2
' Number of constants: 6
' ********************************************************************************************

%icUnknown = 0   ' (&H0)    ' Unknown.
%icDefault = 1   ' (&H1)    ' Default protocol.
%icFTP = 2   ' (&H2)        ' FTP. File Transfer Protocol.
%icGopher = 3   ' (&H3)     ' Gopher
%icHTTP = 4   ' (&H4)       ' HTTP. HyperText Transfer Protocol.
%icHTTPS = 5   ' (&H5)      ' Secure HTTP.

' ********************************************************************************************
' StateConstants enumeration
' Help context: 350012 (&H0005573C)
' Documentation string: States
' Member identifier: 0
' Number of constants: 13
' ********************************************************************************************

%icNone = 0   ' (&H0) No state to report.
%icResolvingHost = 1   ' (&H1) The control is looking up the IP address of the specified host computer.
%icHostResolved = 2   ' (&H2) The control successfully found the IP address of the specified host computer.
%icConnecting = 3   ' (&H3) The control is connecting to the host computer.
%icConnected = 4   ' (&H4) The control successfully connected to the host computer.
%icRequesting = 5   ' (&H5) The control is sending a request to the host computer.
%icRequestSent = 6   ' (&H6) The control successfully sent the request.
%icReceivingResponse = 7   ' (&H7) The control is receiving a response from the host computer.
%icResponseReceived = 8   ' (&H8) The control successfully received a response from the host computer.
%icDisconnecting = 9   ' (&H9) The control is disconnecting from the host computer.
%icDisconnected = 10   ' (&HA) The control successfully disconnected from the host computer.
%icError = 11   ' (&HB) An error occurred in communicating with the host computer.
%icResponseCompleted = 12   ' (&HC) The request has completed and all data has been received.

' ********************************************************************************************
' Global error variable
' ********************************************************************************************
GLOBAL FF_MsInetResult AS DWORD
' ********************************************************************************************

' ********************************************************************************************
' Creates a licensed instance of the Inet class
' ********************************************************************************************
declare FUNCTION MSINET_IClassFactory2_CreateInstanceLic ( _
     BYVAL pthis AS DWORD, _
     BYVAL pUnkOuter AS DWORD, _
     BYVAL pUnkReserved AS DWORD, _
     BYREF riid as GUID, _
     BYVAL pbstrKey AS DWORD, _
     BYREF ppvObj AS DWORD _
     ) AS DWORD

FUNCTION FF_NewInet (OPTIONAL BYVAL strLicKey AS STRING, BYVAL strProgID AS STRING, BYVAL lContext AS LONG) EXPORT AS DWORD
   LOCAL ppv AS DWORD, ppvObj AS DWORD, CLSID_Inet AS GUID, IID_IInet AS GUID, IID_IClassFactory2 AS GUID, pbstrLicKey AS STRING
   IID_IClassFactory2 = GUID$("{b196b28f-bab4-101a-b69c-00aa00341d07}")
   IF ISFALSE lContext THEN lContext = 1  ' %CLSCTX_INPROC_SERVER - Component is allowed in the same process space.
   IF LEN(strProgID) THEN
      IF LEN(GUID$(strProgID)) THEN  ' It is a GUID
         CLSID_Inet = GUID$(strProgID)
      ELSE
         CLSID_Inet = CLSID$(strProgID)  ' It is a ProgID
      END IF
   ELSE
      ' Use the retrieved version independent ProgID
      CLSID_Inet = CLSID$("InetCtls.Inet")
   END IF
   IF LEN(strLicKey) THEN pbstrLicKey = UCODE$(strLicKey) ELSE pbstrLicKey = UCODE$("78E1BDD1-9941-11cf-9756-00AA00C00908")
   FF_MsInetResult = CoGetClassObject(CLSID_Inet, lContext, %NULL, IID_IClassFactory2, ppv)
   IF FF_MsInetResult THEN EXIT FUNCTION
   IID_IInet = GUID$("{48E59291-9880-11CF-9754-00AA00C00908}")
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = ppv : pvtbl = @ppthis : ppmethod = pvtbl + 28 : pmethod = @ppmethod
   CALL DWORD pmethod USING MSINET_IClassFactory2_CreateInstanceLic(ppv, %NULL, %NULL, IID_IInet, STRPTR(pbstrLicKey), ppvObj) TO FF_MsInetResult
   FUNCTION = ppvObj
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Decrements the reference count for the calling interface on a object. If the reference count
' on the object falls to 0, the object is freed from memory.
' Return Value:
' Returns the resulting value of the reference count, which is used for diagnostic/testing
' purposes only.
' ********************************************************************************************
FUNCTION FF_MSINET_Release (BYVAL pthis AS DWORD) AS DWORD

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD, hr AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 8 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSINET_Release(pthis) TO hr
   FUNCTION = hr

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' IInet interface
' Help context: 350043 (&H0005575B)
' Documentation string: Microsoft Internet Transfer Control
' IID: {48E59291-9880-11CF-9754-00AA00C00908}
' Interface flags: &H11D0 [Hidden] [Dual] [Nonextensible] [Oleautomation] [Dispatchable]
' Member identifier: 5
' Number of functions: 32
' ********************************************************************************************

' ********************************************************************************************
' [Get]Protocol property
' Interface name: IInet
' Help context: 350053 (&H00055765)
' Documentation string: Protocol to use for this URL
' VTable offset: 28
' Member identifier: 19
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetProtocol ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF Protocol AS LONG _                                   ' [OUT] <*ProtocolConstants>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetProtocol ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS LONG

   DIM Protocol AS LONG, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 28 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetProtocol(pthis, Protocol) TO FF_MsInetResult
   FUNCTION = Protocol

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]Protocol property
' Interface name: IInet
' Help context: 350053 (&H00055765)
' Documentation string: Protocol to use for this URL
' VTable offset: 32
' Member identifier: 19
' ********************************************************************************************
FUNCTION FF_MSINET_SetProtocol ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL Protocol AS LONG _                                   ' [IN] <ProtocolConstants>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 32 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSINET_SetProtocol(pthis, Protocol) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]RemoteHost property
' Interface name: IInet
' Help context: 350029 (&H0005574D)
' Documentation string: Returns/Sets the remote computer
' VTable offset: 36
' Member identifier: 1
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetRemoteHost ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF RemoteHost AS STRING _                               ' [OUT] <*VT_BSTR <DYNAMIC UNICODE STRING>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetRemoteHost ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS STRING

   DIM RemoteHost AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 36 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetRemoteHost(pthis, RemoteHost) TO FF_MsInetResult
   FUNCTION = ACODE$(RemoteHost)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]RemoteHost property
' Interface name: IInet
' Help context: 350029 (&H0005574D)
' Documentation string: Returns/Sets the remote computer
' VTable offset: 40
' Member identifier: 1
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_SetRemoteHost ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL RemoteHost AS DWORD _                                ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_SetRemoteHost ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL RemoteHost AS STRING _                               ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   RemoteHost = UCODE$(RemoteHost)
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 40 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_SetRemoteHost(pthis, STRPTR(RemoteHost)) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]RemotePort property
' Interface name: IInet
' Help context: 350030 (&H0005574E)
' Documentation string: Returns/Sets the internet port to be used on the remote computer
' VTable offset: 44
' Member identifier: 2
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetRemotePort ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF RemotePort AS INTEGER _                              ' [OUT] <*VT_I2 <INTEGER>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetRemotePort ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS INTEGER

   DIM RemotePort AS INTEGER, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 44 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetRemotePort(pthis, RemotePort) TO FF_MsInetResult
   FUNCTION = RemotePort

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]RemotePort property
' Interface name: IInet
' Help context: 350030 (&H0005574E)
' Documentation string: Returns/Sets the internet port to be used on the remote computer
' VTable offset: 48
' Member identifier: 2
' ********************************************************************************************
FUNCTION FF_MSINET_SetRemotePort ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL RemotePort AS INTEGER _                              ' [IN] VT_I2 <INTEGER>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 48 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSINET_SetRemotePort(pthis, RemotePort) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]ResponseInfo property
' Interface name: IInet
' Help context: 350032 (&H00055750)
' Documentation string: Returns information received from the remote computer
' VTable offset: 52
' Member identifier: 4
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetResponseInfo ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF Response AS STRING _                                 ' [OUT] <*VT_BSTR <DYNAMIC UNICODE STRING>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetResponseInfo ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS STRING

   DIM Response AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 52 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetResponseInfo(pthis, Response) TO FF_MsInetResult
   FUNCTION = ACODE$(Response)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]ResponseCode property
' Interface name: IInet
' Help context: 350033 (&H00055751)
' Documentation string: Returns a response code received from the remote computer
' VTable offset: 56
' Member identifier: 5
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetResponseCode ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF Code AS LONG _                                       ' [OUT] <*VT_I4 <LONG>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetResponseCode ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS LONG

   DIM Code AS LONG, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 56 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetResponseCode(pthis, Code) TO FF_MsInetResult
   FUNCTION = Code

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]hInternet property
' Interface name: IInet
' Help context: 350034 (&H00055752)
' Documentation string: Returns the low-level internet handle for this control
' VTable offset: 60
' Member identifier: 6
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GethInternet ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF prmHandle AS LONG _                                  ' [OUT] <*VT_I4 <LONG>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GethInternet ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS LONG

   DIM prmHandle AS LONG, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 60 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GethInternet(pthis, prmHandle) TO FF_MsInetResult
   FUNCTION = prmHandle

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]StillExecuting property
' Interface name: IInet
' Help context: 350035 (&H00055753)
' Documentation string: Returns whether this control is currently busy
' VTable offset: 64
' Member identifier: 8
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetStillExecuting ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF IsBusy AS INTEGER _                                  ' [OUT] <*VT_BOOL <INTEGER>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetStillExecuting ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS INTEGER

   DIM IsBusy AS INTEGER, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 64 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetStillExecuting(pthis, IsBusy) TO FF_MsInetResult
   FUNCTION = IsBusy

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]URL property
' Interface name: IInet
' Help context: 350036 (&H00055754)
' Documentation string: Returns/Sets the URL used by this control
' VTable offset: 68
' Member identifier: 9
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetURL ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF URL AS STRING _                                      ' [OUT] <*VT_BSTR <DYNAMIC UNICODE STRING>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetURL ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS STRING

   DIM URL AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 68 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetURL(pthis, URL) TO FF_MsInetResult
   FUNCTION = ACODE$(URL)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]URL property
' Interface name: IInet
' Help context: 350036 (&H00055754)
' Documentation string: Returns/Sets the URL used by this control
' VTable offset: 72
' Member identifier: 9
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_SetURL ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL URL AS DWORD _                                       ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_SetURL ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL URL AS STRING _                                      ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   URL = UCODE$(URL)
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 72 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_SetURL(pthis, STRPTR(URL)) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]Proxy property
' Interface name: IInet
' Help context: 350059 (&H0005576B)
' Documentation string: Proxy server to use when accessing the net
' VTable offset: 76
' Member identifier: 24
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetProxy ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF prmName AS STRING _                                  ' [OUT] <*VT_BSTR <DYNAMIC UNICODE STRING>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetProxy ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS STRING

   DIM prmName AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 76 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetProxy(pthis, prmName) TO FF_MsInetResult
   FUNCTION = ACODE$(prmName)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]Proxy property
' Interface name: IInet
' Help context: 350059 (&H0005576B)
' Documentation string: Proxy server to use when accessing the net
' VTable offset: 80
' Member identifier: 24
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_SetProxy ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL pbstrName AS DWORD _                                 ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_SetProxy ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL pbstrName AS STRING _                                ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   pbstrName = UCODE$(pbstrName)
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 80 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_SetProxy(pthis, STRPTR(pbstrName)) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]Document property
' Interface name: IInet
' Help context: 350037 (&H00055755)
' Documentation string: Returns/Sets the Document to be retrieved from server
' VTable offset: 84
' Member identifier: 10
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetDocument ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF Document AS STRING _                                 ' [OUT] <*VT_BSTR <DYNAMIC UNICODE STRING>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetDocument ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS STRING

   DIM Document AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 84 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetDocument(pthis, Document) TO FF_MsInetResult
   FUNCTION = ACODE$(Document)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]Document property
' Interface name: IInet
' Help context: 350037 (&H00055755)
' Documentation string: Returns/Sets the Document to be retrieved from server
' VTable offset: 88
' Member identifier: 10
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_SetDocument ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL Document AS DWORD _                                  ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_SetDocument ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL Document AS STRING _                                 ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   Document = UCODE$(Document)
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 88 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_SetDocument(pthis, STRPTR(Document)) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]AccessType property
' Interface name: IInet
' Help context: 350041 (&H00055759)
' Documentation string: Returns/Sets the proxy behavior for this control's connections
' VTable offset: 92
' Member identifier: 14
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetAccessType ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF prmType AS LONG _                                    ' [OUT] <*AccessConstants>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetAccessType ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS LONG

   DIM prmType AS LONG, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 92 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetAccessType(pthis, prmType) TO FF_MsInetResult
   FUNCTION = prmType

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]AccessType property
' Interface name: IInet
' Help context: 350041 (&H00055759)
' Documentation string: Returns/Sets the proxy behavior for this control's connections
' VTable offset: 96
' Member identifier: 14
' ********************************************************************************************
FUNCTION FF_MSINET_SetAccessType ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL prmType AS LONG _                                    ' [IN] <AccessConstants>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 96 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSINET_SetAccessType(pthis, prmType) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]UserName property
' Interface name: IInet
' Help context: 350054 (&H00055766)
' Documentation string: User name to use for authentication
' VTable offset: 100
' Member identifier: 20
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetUserName ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF UserName AS STRING _                                 ' [OUT] <*VT_BSTR <DYNAMIC UNICODE STRING>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetUserName ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS STRING

   DIM UserName AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 100 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetUserName(pthis, UserName) TO FF_MsInetResult
   FUNCTION = ACODE$(UserName)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]UserName property
' Interface name: IInet
' Help context: 350054 (&H00055766)
' Documentation string: User name to use for authentication
' VTable offset: 104
' Member identifier: 20
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_SetUserName ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL UserName AS DWORD _                                  ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_SetUserName ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL UserName AS STRING _                                 ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   UserName = UCODE$(UserName)
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 104 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_SetUserName(pthis, STRPTR(UserName)) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]Password property
' Interface name: IInet
' Help context: 350055 (&H00055767)
' Documentation string: Password to use for authentication
' VTable offset: 108
' Member identifier: 21
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetPassword ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF Password AS STRING _                                 ' [OUT] <*VT_BSTR <DYNAMIC UNICODE STRING>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetPassword ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS STRING

   DIM Password AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 108 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetPassword(pthis, Password) TO FF_MsInetResult
   FUNCTION = ACODE$(Password)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]Password property
' Interface name: IInet
' Help context: 350055 (&H00055767)
' Documentation string: Password to use for authentication
' VTable offset: 112
' Member identifier: 21
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_SetPassword ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL Password AS DWORD _                                  ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_SetPassword ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL Password AS STRING _                                 ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   Password = UCODE$(Password)
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 112 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_SetPassword(pthis, STRPTR(Password)) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Get]RequestTimeout property
' Interface name: IInet
' Help context: 350062 (&H0005576E)
' Documentation string: Gets/Sets number of seconds to wait for request to complete
' VTable offset: 116
' Member identifier: 26
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetRequestTimeout ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF prmTimeout AS LONG _                                 ' [OUT] <*VT_I4 <LONG>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetRequestTimeout ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS LONG

   DIM prmTimeout AS LONG, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 116 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetRequestTimeout(pthis, prmTimeout) TO FF_MsInetResult
   FUNCTION = prmTimeout

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]RequestTimeout property
' Interface name: IInet
' Help context: 350062 (&H0005576E)
' Documentation string: Gets/Sets number of seconds to wait for request to complete
' VTable offset: 120
' Member identifier: 26

' ********************************************************************************************
FUNCTION FF_MSINET_SetRequestTimeout ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL prmTimeout AS LONG _                                 ' [IN] VT_I4 <LONG>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 120 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSINET_SetRequestTimeout(pthis, prmTimeout) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' OpenURL method
' Interface name: IInet
' Help context: 350057 (&H00055769)
' Documentation string: Open a URL
' VTable offset: 124
' Member identifier: 22
' ********************************************************************************************
FUNCTION FF_MSINET_OpenURL ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL URL AS VARIANT, _                                    ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYVAL DataType AS VARIANT, _                               ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYREF pRetval AS VARIANT _                                 ' [OUT] <*VT_VARIANT <VARIANT>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 124 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSINET_OpenURL(pthis, URL, DataType, pRetval) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Execute method
' Interface name: IInet
' Help context: 350044 (&H0005575C)
' Documentation string: Issue a request to the remote computer
' VTable offset: 128
' Member identifier: 17
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_Execute ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL URL AS VARIANT, _                                    ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYVAL Operation AS VARIANT, _                              ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYVAL InputData AS VARIANT, _                              ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYVAL InputHdrs AS VARIANT _                               ' [IN] [OPT] VT_VARIANT <VARIANT>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_Execute ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   OPTIONAL BYVAL URL AS VARIANT, _                           ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYVAL Operation AS VARIANT, _                              ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYVAL InputData AS VARIANT, _                              ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYVAL InputHdrs AS VARIANT _                               ' [IN] [OPT] VT_VARIANT <VARIANT>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   IF VARIANTVT(URL) = %VT_EMPTY THEN URL = ERROR %DISP_E_PARAMNOTFOUND
   IF VARIANTVT(Operation) = %VT_EMPTY THEN Operation = ERROR %DISP_E_PARAMNOTFOUND
   IF VARIANTVT(InputData) = %VT_EMPTY THEN InputData = ERROR %DISP_E_PARAMNOTFOUND
   IF VARIANTVT(InputHdrs) = %VT_EMPTY THEN InputHdrs = ERROR %DISP_E_PARAMNOTFOUND
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 128 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_Execute(pthis, URL, Operation, InputData, InputHdrs) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Cancel method
' Interface name: IInet
' Help context: 350045 (&H0005575D)
' Documentation string: Method used to cancel the request currently being executed
' VTable offset: 132
' Member identifier: 18
' ********************************************************************************************
FUNCTION FF_MSINET_Cancel ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 132 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSINET_Cancel(pthis) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' GetChunk method
' Interface name: IInet
' Help context: 350058 (&H0005576A)
' Documentation string: Retrieve part of document
' VTable offset: 136
' Member identifier: 23
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetChunk ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF prmSize AS LONG, _                                   ' [IN] [OUT] <*VT_I4 <LONG>>
   BYVAL DataType AS VARIANT, _                               ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYREF pRetval AS VARIANT _                                 ' [OUT] <*VT_VARIANT <VARIANT>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetChunk ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF prmSize AS LONG, _                                   ' [IN] [OUT] <*VT_I4 <LONG>>
   BYVAL DataType AS VARIANT, _                               ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYREF pRetval AS VARIANT _                                 ' [OUT] <*VT_VARIANT <VARIANT>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 136 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetChunk(pthis, prmSize, DataType, pRetval) TO FF_MsInetResult
   FUNCTION = FF_MsInetResult

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' GetHeader method
' Interface name: IInet
' Help context: 350060 (&H0005576C)
' Documentation string: Returns a named header or all headers
' VTable offset: 140
' Member identifier: 25
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_GetHeader ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL HdrName AS VARIANT, _                                ' [IN] [OPT] VT_VARIANT <VARIANT>
   BYREF pRetval AS STRING _                                  ' [OUT] <*VT_BSTR <DYNAMIC UNICODE STRING>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_GetHeader ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL HdrName AS VARIANT _                                 ' [IN] [OPT] VT_VARIANT <VARIANT>
   ) AS STRING

   DIM pRetVal AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 140 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_GetHeader(pthis, HdrName, pRetval) TO FF_MsInetResult
   FUNCTION = ACODE$(pRetVal)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' AboutBox method  [Hidden]
' Interface name: IInet
' VTable offset: 144
' Member identifier: -552
' ********************************************************************************************
SUB FF_MSINET_AboutBox ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   )                                                          ' VT_VOID

   IF pthis = 0 THEN FF_MsInetResult = -1 : EXIT SUB
   DIM ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 144 : pmethod = @ppmethod
   CALL DWORD pmethod USING FF_MSINET_AboutBox(pthis)

END SUB
' ********************************************************************************************

' ********************************************************************************************
' [Get]_URL property  [Hidden]
' Interface name: IInet
' VTable offset: 148
' Member identifier: 0
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_Get_URL ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYREF URL AS STRING _                                      ' [OUT] <*VT_BSTR <DYNAMIC UNICODE STRING>>
   ) AS DWORD                                                 ' VT_HRESULT <DWORD>

FUNCTION FF_MSINET_Get_URL ( _
   BYVAL pthis AS DWORD _                                     ' VT_PTR <*VT_UNKNOWN>
   ) AS STRING

   DIM URL AS STRING, ppthis AS DWORD PTR, pvtbl AS DWORD PTR, ppmethod AS DWORD PTR, pmethod AS DWORD
   ppthis = pthis : pvtbl = @ppthis : ppmethod = pvtbl + 148 : pmethod = @ppmethod
   CALL DWORD pmethod USING Proto_FF_MSINET_Get_URL(pthis, URL) TO FF_MsInetResult
   FUNCTION = ACODE$(URL)

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' [Set]_URL property  [Hidden]
' Interface name: IInet
' VTable offset: 152
' Member identifier: 0
' ********************************************************************************************
DECLARE FUNCTION Proto_FF_MSINET_Set_URL ( _
   BYVAL pthis AS DWORD, _                                    ' VT_PTR <*VT_UNKNOWN>
   BYVAL URL AS DWORD _                                       ' [IN] VT_BSTR <DYNAMIC UNICODE STRING>
   ) AS DWORD            

Jose Roca

And finally, the events code for MSINET.


' ********************************************************************************************
' OnEvent Functions
' Code generated by the TypeLib Browser v. 1.03 (c) 2003-2004 by Jose Roca
' Date: 14 jul 2004   Time: 16:11:18
' ********************************************************************************************
' Variants can hold any kind of numeric values. When returning one of these values you can
' assign them directly, e.g. #pvapi[1].vd.@plVal = -1, but when you need to assign an string
' or a variant you need to declare a variable of the appropiate kind and pass his address with
' VARPTR. Strings must be converted to unicode with UCODE$. You have to manipulate the variant
' using pointers because when you assign a value to a byref variant with PB, the variant loses
' his byref flag and PB doesn't provide a way to set it.
' ********************************************************************************************



' ********************************************************************************************
' DInetEvents dispatch interface
' Help context: 350042 (&H0005575A)
' Documentation string: Event interface for Microsoft Internet Transfer Control
' GUID: {48E59292-9880-11CF-9754-00AA00C00908}
' Member identifier: 6
' Number of functions: 1
' ********************************************************************************************

' ********************************************************************************************
' Builds the IDispatch Virtual Table
' ********************************************************************************************
SUB FF_MsInetEvents_BuildVtbl (Vtbl AS TB_IDispatchVtbl)
  VTbl.QueryInterface   = CODEPTR(FF_MsInetEvents_QueryInterface)
  VTbl.AddRef           = CODEPTR(FF_MsInetEvents_AddRef)
  VTbl.Release          = CODEPTR(FF_MsInetEvents_Release)
  VTbl.GetTypeInfoCount = CODEPTR(FF_MsInetEvents_GetTypeInfoCount)
  VTbl.GetTypeInfo      = CODEPTR(FF_MsInetEvents_GetTypeInfo)
  VTbl.GetIDsOfNames    = CODEPTR(FF_MsInetEvents_GetIDsOfNames)
  VTbl.Invoke           = CODEPTR(FF_MsInetEvents_Invoke)
END SUB
' ********************************************************************************************

' ********************************************************************************************
' HRESULT QueryInterface([in] *GUID riid, [out] **VOID ppvObj)
' ********************************************************************************************
FUNCTION FF_MsInetEvents_QueryInterface (BYVAL pthis AS DWORD, BYREF riid AS GUID, BYREF ppvObj AS DWORD) AS DWORD
  STATIC pSink AS DWORD, Vtbl AS TB_IDispatchVtbl
  FF_MsInetEvents_BuildVtbl(Vtbl)
  pSink = VARPTR(Vtbl)
  ppvObj = VARPTR(pSink)
  FUNCTION = 0 ' %S_OK
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' UI4 AddRef()
' ********************************************************************************************
FUNCTION FF_MsInetEvents_AddRef (BYVAL pthis AS DWORD) AS DWORD
  FUNCTION = 1
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' UI4 Release()
' ********************************************************************************************
FUNCTION FF_MsInetEvents_Release (BYVAL pthis AS DWORD) AS DWORD
  FUNCTION = 1
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' HRESULT GetTypeInfoCount([out] *UINT pctinfo)
' ********************************************************************************************
FUNCTION FF_MsInetEvents_GetTypeInfoCount (BYVAL pthis AS DWORD, BYREF pctInfo AS DWORD) AS DWORD
  FUNCTION = &H80004001 ' %E_NOTIMPL
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' HRESULT GetTypeInfo([in] UINT itinfo, [in] UI4 lcid, [out] **VOID pptinfo)
' ********************************************************************************************
FUNCTION FF_MsInetEvents_GetTypeInfo (BYVAL pthis AS DWORD, BYVAL itinfo AS DWORD, BYVAL lcid AS DWORD, BYREF pptinfo AS DWORD) AS DWORD
  FUNCTION = &H80004001 ' %E_NOTIMPL
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' HRESULT GetIDsOfNames([in] *GUID riid, [in] **I1 rgszNames, [in] UINT cNames, [in] UI4 lcid, [out] *I4 rgdispid)
' ********************************************************************************************
FUNCTION FF_MsInetEvents_GetIDsOfNames (BYVAL pthis AS DWORD, BYREF riid AS GUID, BYVAL rgszNames AS DWORD, BYVAL cNames AS DWORD, BYVAL lcid AS DWORD, BYREF rgdispid AS LONG) AS DWORD
  FUNCTION = &H80004001 ' %E_NOTIMPL
END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Establishes a connection between the connection point object and the client's sink.
' Returns a token that uniquely identifies this connection.
' ********************************************************************************************
FUNCTION FF_MsInetEvents_SetEvents (BYVAL pthis AS DWORD, BYREF pdwCookie AS DWORD) AS DWORD

  LOCAL HRESULT AS DWORD                ' HRESULT code
  LOCAL pCPC AS DWORD                   ' IConnectionPointContainer
  LOCAL pCP AS DWORD                    ' IConnectionPoint
  LOCAL IID_CPC AS GUID                 ' IID_IConnectionPointContainer
  LOCAL IID_CP AS GUID                  ' Events dispinterface
  LOCAL pSink AS DWORD                  ' Pointer to our sink interface
  LOCAL dwCookie AS DWORD               ' Returned token
  STATIC Vtbl AS TB_IDispatchVtbl       ' Vtbl structure

  IID_CPC = GUID$("{B196B284-BAB4-101A-B69C-00AA00341D07}")
  IID_CP  = GUID$("{48E59292-9880-11CF-9754-00AA00C00908}")

  HRESULT = IUnknown_QueryInterface(pthis, IID_CPC, pCPC)
  IF HRESULT <> 0 THEN FUNCTION = HRESULT : EXIT FUNCTION

  HRESULT = IConnectionPointContainer_FindConnectionPoint(pCPC, IID_CP, pCP)
  IUnknown_Release pCPC
  IF HRESULT <> 0 THEN FUNCTION = HRESULT : EXIT FUNCTION

  FF_MsInetEvents_BuildVtbl(Vtbl)
  pSink = VARPTR(Vtbl)
  HRESULT = IConnectionPoint_Advise(pCP, BYVAL VARPTR(pSink), dwCookie)

  pdwCookie = dwCookie
  IUnknown_Release pCP
  FUNCTION = HRESULT

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Releases the events connection identified with the cookie returned by the SetEvents function
' ********************************************************************************************
FUNCTION FF_MsInetEvents_ReleaseEvents (BYVAL pthis AS DWORD, BYVAL dwCookie AS DWORD) AS DWORD

  LOCAL HRESULT AS DWORD                ' HRESULT code
  LOCAL pCPC AS DWORD                   ' IConnectionPointContainer
  LOCAL pCP AS DWORD                    ' IConnectionPoint
  LOCAL IID_CPC AS GUID                 ' IID_IConnectionPointContainer
  LOCAL IID_CP AS GUID                  ' ConnectionEvents dispinterface

  IID_CPC = GUID$("{B196B284-BAB4-101A-B69C-00AA00341D07}")
  IID_CP  = GUID$("{48E59292-9880-11CF-9754-00AA00C00908}")

  HRESULT = Iunknown_QueryInterface(pthis, IID_CPC, pCPC)
  IF HRESULT <> 0 THEN FUNCTION = HRESULT : EXIT FUNCTION

  HRESULT = IConnectionPointContainer_FindConnectionPoint(pCPC, IID_CP, pCP)
  IUnknown_Release pCPC
  IF HRESULT <> 0 THEN FUNCTION = HRESULT : EXIT FUNCTION

  HRESULT = IConnectionPoint_Unadvise(pCP, dwCookie)
  IUnknown_Release pCP
  FUNCTION = HRESULT

END FUNCTION
' ********************************************************************************************

' ********************************************************************************************
' Function name: StateChanged
' Dispatch interface name: DInetEvents
' Help context: 350067 (&H00055773)
' Documentation string: StateChanged event
' Member identifier: 32
' ********************************************************************************************
FUNCTION FF_MsInetEvents_StateChanged (BYVAL dwCookie AS DWORD, BYREF pdispparams AS DISPPARAMS) AS DWORD
  LOCAL pv AS VARIANT PTR, pvapi AS VARIANTAPITYPE PTR
  pv = pdispparams.VariantArgs : pvapi = pv
'  ==============================================================================
'  Parameters in DISPPARAMS are zero based and in reverse order
'  ==============================================================================
  LOCAL prmState AS INTEGER
  prmState = VARIANT#(@pv[0])
'  ==============================================================================
'  *** Put your code here ***
'  ==============================================================================
  FUNCTION = 0 ' %S_OK
END FUNCTION
' ********************************************************************************************


' ********************************************************************************************
' HRESULT Invoke([in] I4 dispidMember, [in] *GUID riid, [in] UI4 lcid, [in] UI2 wFlags, [in] *DISPPARAMS pdispparams, [out] *VARIANT pvarResult, [out] *EXCEPINFO pexcepinfo, [out] *UINT puArgErr)
' ********************************************************************************************
FUNCTION FF_MsInetEvents_Invoke (BYVAL dwCookie AS DWORD, BYVAL dispidMember AS LONG, BYREF riid AS GUID, _
 BYVAL lcid AS DWORD, BYVAL wFlags AS WORD, BYREF pdispparams AS DISPPARAMS, BYREF pvarResult AS VARIANT, _
 BYREF pexcepinfo AS EXCEPINFO, BYREF puArgErr AS DWORD) AS DWORD

  FUNCTION = 0 ' %S_OK
  IF VARPTR(pdispparams) THEN

     SELECT CASE AS LONG dispidMember
        CASE &H20  ' (32)  ' // StateChanged
           FUNCTION = FF_MsInetEvents_StateChanged(dwCookie, pdispparams)

     END SELECT
  END IF

END FUNCTION
' ********************************************************************************************

David Martin

I use SocketTools from Catalyst http://www.catalyst.com/support/index.html I have both the DLL & ActiveX versions and they work great.

Anonymous

SocketTools looks to be good, but unfortunately too highly priced for my liking (I'm not stingey, it's just that I can't justify several hundred bucks without good reason).

I used DLLs available from MarshallSoft - http://www.marshallsoft.com for doing FTP and email, but they have a number of different products for different purposes. And I'd say from having used the products over a period of time that the guy who authors them probably knows his stuff.

Andrew

David Martin

I have the WSC ( Windows Standard Serial Comm Library ) from MarshallSoft for PB, VB & FoxPro and it has always worked well for me.

Roger Garstang

I knew this sounded like a job for Jose...Hopefully I can figure out how to use all this now.  Do you know offhand what versions of windows are needed for these?

Jose Roca

Versions of Windows: The same as for Visual Basic 6. These are OCXs that come with Visual Studio 6.0. If you don't have them, a search in Google will give you links to download. There is a link from Microsoft where you can download all of them in the form of .cab files, but I can't find the link at this moment.

Regarding the wrapper functions, no need to look inside. They contain boring code to calculate the address of the function and to call it using CALL DWORD. To use them is easy. Just create an instance of the object, e.g. lpWinsock = NewLicMSWinsock, and call them as regular functions. When you not longer need the control or when your program is going to end, release it with MsWinsock_Release lpWinsock. I have edited the post to include this function and to correct the name of NewLicMSWinsock, that was named ad NewLicMSWinsockWinsock.

The first parameter is always the pointer to the instance of the control. Think of LoadLibrary/FreeLibrary, where you load a DLL with LoadLibrary and you free it with FreeLibrary when no longer needed.

There is a lot of power inside these bunch of OCXs and COM DLLs already installed on your system or freely available. As all the information is contained in the typelib, I can produce wrapper functions in little time even without knowing anything about what they do.

Anonymous

You have to be careful about redistributing files which are included with Microsoft Visual Studio. I seem to recall that permission was granted to redistribute IF they went with an application created with Visual Studio.

I haven't looked at the Microsoft EULA in a while but I would advise this needs checking, just in case you are thinking of writing a distributable application.

Andrew

Jose Roca

Here is the Microsoft link where you can download these .cab files:

http://support.microsoft.com/default.aspx?scid=kb;en-us;193366

I doubt that there is an updated EULA, since Microsoft seems not longer care about old products (now everything is .NET). So perhaps this is like prostitution in my country: it is not legal, but it is not punished (sorry for the comparation). Some of them, like MSCAL.OCX, have being incorporated in XP as a system OCX.