title: Using wininet.dll to retrieve FTP command output
body: <p>I'm trying to find a simple way of checking user stats via FTP, wininet seems to be the best option.
  How do I get the output from the command though?</p>
  
  <pre><code>Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal HINet As Integer) As Integer
  Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Integer, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Integer) As Integer
  Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Integer, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Integer, ByVal lFlags As Integer, ByVal lContext As Integer) As Integer
  Public Declare Function ftpCommand Lib "wininet.dll" Alias "FtpCommandA" (ByVal hConnect As Integer, ByVal fExpectResponse As Boolean, ByVal dwFlags As Integer, ByVal lpszCommand As String, ByRef dwContext As Integer, ByRef phFtpCommand As Integer) As Boolean
  
  Dim INet, INetConn As Integer
  
  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  
      INet = InternetOpen("MyFTP", 1, vbNullString, vbNullString, 0)
      INetConn = InternetConnect(INet, "192.168.1.6", 21, "user", "pwd", 1, 0, 0)
  
      strCommand = "SITE SHOW SERVER 192.168.1.6.21"
  
      Dim retv As Long
      Dim Test = ftpCommand(INetConn, True, 2, strCommand, 0, retv)
      Debug.Write(Test)
  
      InternetCloseHandle(INetConn)
      InternetCloseHandle(INet)
  
  End Sub
  </code></pre>
  
  <p>The output I'm expecting is:</p>
  
  <pre><code>Response:   200- Server IP = "192.168.1.6"
  Response:   200- Port = "21"
  Response:   200- Start time = "10/02/2010  02:46:57 PM"
  Response:   200- Download = "0.000 KB"
  Response:   200- Upload = "0.000 KB"
  Response:   200- Online Users = "0"
  Response:   200-======================================
  Response:   200 Site command OK
  </code></pre>
  
  <p>Thanks.</p>