Error compile
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Error compile

Threaded View

  1. #1
    Join Date
    May 2013
    Posts
    5

    Error compile

    I can run it, but can't run with full compile, anything wrong with my code? help me please:RESOLVED already
    Code:
    Option Explicit
    
    Private Type hostent
        h_name As Long
        h_aliases As Long
        h_addrtype As Integer
        h_length As Integer
        h_addr_list As Long
    End Type
    
    Private Declare Function inet_addr Lib "wsock32.dll" (ByVal addr As String) As Long
    Private Declare Function gethostbyaddr Lib "wsock32" (addr As Long, addrLen As Long, addrType As Long) As Long
    Private Declare Sub RtlMoveMemory Lib "kernel32" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
    
    Private objSystray As clsSysTray
    
    Private Const DEBUG_MODE = False
    
    Dim BlockingClient() As Boolean
    Dim BlockingServer() As Boolean
    
    Dim ServerConnection As Collection
    Dim ClientConnection As Collection
    
    Private Sub cmdClearLog_Click()
        lstLog.Clear
        txtRequest.Text = ""
        txtResponse.Text = ""
    End Sub
    
    Private Sub cmdConfiguration_Click()
        LoadConfigurationScreen Me, netProxy
    End Sub
    
    Private Sub cmdSwitch_Click()
        If cmdSwitch.Caption = "Start" Then
            objSystray.ToolTip = "Tere Injector On"
            StartProxy ListeningPort
            cmdSwitch.Caption = "Stop"
            
            Else
            objSystray.ToolTip = "Tere Injector On"
            StopProxy
            cmdSwitch.Caption = "Start"
        
        End If
    End Sub
    Private Sub StartProxy(LocalPort As Long)
    Dim Socket As Winsock
    For Each Socket In sckServer
    tmrServer(Socket.Index).Enabled = True
    tmrClient(Socket.Index).Enabled = True
    DoEvents
    Next
    'starting the server by binding the local port property to the listening port we use for proxy
    'and issue the listen method to start listening
    InitializeSocket sckServer(0)
    sckServer(0).LocalPort = LocalPort
    sckServer(0).Listen
    End Sub
    
    Private Sub StopProxy()
    Dim Socket As Winsock
    
        SendMessage "Shutting down Personal Proxy Server"
        For Each Socket In sckServer
            tmrServer(Socket.Index).Enabled = False
            tmrClient(Socket.Index).Enabled = False
            DoEvents
            CloseSocket Socket.Index
        Next
        SendMessage "Personal Proxy Server stopped"
    End Sub
    
    Private Sub InitializeSocket(Socket As Winsock)
    On Error Resume Next
    
        SendMessage "Initialize Socket " & Socket.LocalPort
        Socket.Close
        Socket.LocalPort = 0
    End Sub
    
    Private Sub SendMessage(Message As String)
        lstLog.AddItem "[" & Now & "] " & Message
        If lstLog.ListCount > 10000 Then lstLog.Clear
    End Sub
    
    Private Sub Combo1_Change()
      If Combo1.Text = "THREE" Then
         Combo1.Text = TRI
         Else
         Combo1.Text = TSEL
      End If
       
    End Sub
    
    Private Sub flxStatistic_Click()
    Dim i As Long
    
        With flxStatistic
            For i = 1 To ConnectionRequest.Count
                DoEvents
                If i = .Rows Then
                    .Rows = .Rows + 1
                    .TextMatrix(i, 0) = i
                    .TextMatrix(i, 1) = ConnectionRequest(i).IPAddress
                    If ConnectionRequest(i).HostName = "" Then
                        ConnectionRequest(i).HostName = NameByAddr(ConnectionRequest(i).IPAddress)
                    End If
                    .TextMatrix(i, 2) = ConnectionRequest(i).HostName
                End If
                .TextMatrix(i, 3) = ConnectionRequest(i).Stat_Connect_Count
                .TextMatrix(i, 4) = FormatByte(ConnectionRequest(i).Stat_Bytes_Received)
                .TextMatrix(i, 5) = FormatByte(ConnectionRequest(i).Stat_Bytes_Sent)
            Next i
        End With
    End Sub
    
    Private Sub flxStatistic_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbRightButton And Shift = vbCtrlMask Then
            PopupMenu mnuStat, , X + 250, Y + 1100
        End If
    End Sub
    
    Private Sub Form_Load()
    Skin1.ApplySkin Me.hwnd
            chkLog.Value = False
    Combo1.AddItem "THREE"
    Combo1.AddItem "TSEL"
    
        If App.PrevInstance Then
            End
        End If
        
        LocalIP = sckServer(0).LocalIP
        LoadUser UserList, "UserList.txt"
        LoadUser InvalidList, "Invalid.txt"
        InitializeGrid
        
        Set netProxy = New CProxy
        If Len(App.Path & "\" & ConfigFileName) = 0 Then LocalComputerName = sckServer(0).LocalHostName
        LoadProxyConfiguration
        Set ServerConnection = New Collection
        Set ClientConnection = New Collection
    
        Set objSystray = New clsSysTray
        Set objSystray.SourceWindow = Me
        objSystray.ChangeIcon Me.Icon
        objSystray.ToolTip = "Tere Injector"
    End Sub
    
    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        If cmdSwitch.Caption <> "Start" Then
            objSystray.ToolTip = "Personal Proxy Server Off"
            StopProxy
            cmdSwitch.Caption = "Start"
        End If
    End Sub
    
    Private Sub Form_Resize()
        tabProxy.Width = Me.ScaleWidth
        If Me.ScaleHeight > (cmdSwitch.Height) Then
            tabProxy.Height = Me.ScaleHeight - (cmdSwitch.Height)
        End If
        If tabProxy.Width > 200 Then
            fraLog.Width = tabProxy.Width - 200
            fraStat.Width = tabProxy.Width - 200
        End If
        If tabProxy.Height > 500 Then
            fraLog.Height = tabProxy.Height - 500
            fraStat.Height = tabProxy.Height - 500
        End If
        If fraLog.Width > 200 Then
            lstLog.Width = fraLog.Width - 200
            flxStatistic.Width = fraStat.Width - 200
        End If
        If fraLog.Height > 240 Then
            lstLog.Height = fraLog.Height - 240
        End If
        If fraStat.Height > 320 Then
            flxStatistic.Height = fraStat.Height - 320
        End If
        fraRequest.Width = fraLog.Width
        fraRequest.Height = fraLog.Height \ 2
        If fraRequest.Height > 400 Then
            txtRequest.Height = fraRequest.Height - 400
        End If
        If fraRequest.Width > 300 Then
            txtRequest.Width = fraRequest.Width - 300
        End If
        fraResponse.Top = fraRequest.Top + fraRequest.Height
        fraResponse.Width = fraLog.Width
        fraResponse.Height = fraLog.Height \ 2
        If fraResponse.Height > 400 Then
            txtResponse.Height = fraResponse.Height - 400
        End If
        If fraResponse.Width > 300 Then
            txtResponse.Width = fraResponse.Width - 300
        End If
        
        With flxStatistic
            .ColWidth(0) = Abs(360 / 6165 * (.Width - 100))
            .ColWidth(1) = Abs(960 / 6165 * (.Width - 100))
            .ColWidth(2) = Abs(2010 / 6165 * (.Width - 100))
            .ColWidth(3) = Abs(915 / 6165 * (.Width - 100))
            .ColWidth(4) = Abs(960 / 6165 * (.Width - 100))
            .ColWidth(5) = Abs(960 / 6165 * (.Width - 100))
            
        End With
    
        If Me.WindowState = vbMinimized Then
            If cmdSwitch.Caption = "Stop" Then
                objSystray.ChangeIcon Me.Icon
            Else
                objSystray.ChangeIcon frmUserLogin.Icon
            End If
            objSystray.MinToSysTray
        End If
        
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    Dim Socket As Winsock
    
        On Error Resume Next
        For Each Socket In sckClient
            CloseSocket Socket.Index
            If Socket.Index <> 0 Then
                Unload Socket
            End If
        Next
        
        For Each Socket In sckServer
            CloseSocket Socket.Index
            If Socket.Index <> 0 Then
                Unload Socket
            End If
        Next
            
        Set netProxy = Nothing
        Set ServerConnection = Nothing
        Set ClientConnection = Nothing
    
        objSystray.RemoveFromSysTray
        
        Set objSystray = Nothing
    End Sub
    
    Private Sub lstLog_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If Button = vbRightButton Then
            PopupMenu mnuLog, vbPopupMenuRightButton, X + 240, Y + 1060
        End If
    End Sub
    
    Private Sub mnuClearHeader_Click()
        txtRequest.Text = ""
        txtResponse.Text = ""
    End Sub
    
    Private Sub mnuClearLog_Click()
        lstLog.Clear
    End Sub
    
    Private Sub mnuSave_Click()
        SaveUser InvalidList, "Invalid.txt"
    End Sub
    
    Private Sub Option1_Click()
    Option2.Value = False
    
    End Sub
    
    Private Sub Option2_Click()
    Option1.Value = False
    
    End Sub
    
    Private Sub sckClient_Close(Index As Integer)
        InitializeSocket sckClient(Index)
    '    ClientConnection(Index).ClearBuffer
    '
    '    If Index <> 0 Then
    '        Do While Len(ServerConnection(Index).SendBuffer) <> 0 Or sckServer(Index).State = sckClosed
    '            DoEvents
    '        Loop
    '        InitializeSocket sckServer(Index)
    '        ServerConnection(Index).ClearBuffer
    '    End If
    End Sub
    
    Private Sub sckClient_Connect(Index As Integer)
    Dim vData As String
    Dim tg As String
    
    If Combo1.Text = "THREE" Then
       tg = "GET http://internet.three.co.id/ HTTP/1.1" & vbLf & "Host: internet.three.co.id" & vbLf & vbLf
       Else
       tg = "GET http://m.facebook.com/ HTTP/1.1" & vbCrLf & "Host: m.facebook.com" & vbCrLf & vbCrLf & vbCrLf
    End If
    
        'send the data when connected
        If sckClient(Index).State = sckConnected Then
            vData = ClientConnection(Index).SendBuffer
            If Len(vData) <> 0 Then
                vData = ClientConnection(Index).SendBuffer.GetString
                SendDataTo sckClient(Index), tg & vData
                SendMessage "Connected to Server " & sckClient(Index).RemoteHostIP & ":" & sckClient(Index).RemotePort
                If DEBUG_MODE Then Debug.Print "send to server " & vbCrLf & vData
            End If
    End If
      
    End Sub
    
    Private Sub sckClient_DataArrival(Index As Integer, ByVal bytesTotal As Long)
    Dim vData As String
    Dim lpos As Long
    Dim Header As String, Data As String
    
        If Index <> 0 And sckClient(Index).State = sckConnected Then
            SendMessage "Receive data from server " & sckClient(Index).RemoteHostIP & ":" & sckClient(Index).RemotePort & " size: " & bytesTotal & " bytes"
            
            sckClient(Index).GetData vData
            ServerConnection(Index).Append vData
            AppendLog Index, "From Server " & Index & " :" & vbCrLf & vData
            
            If ServerConnection(Index).HeaderReceived And Not ServerConnection(Index).Connected Then
                If DEBUG_MODE Then Debug.Print "received from server " & vbCrLf & ServerConnection(Index).Header
                Header = FilterResponseHeader(ServerConnection(Index).Header)
                ServerConnection(Index).SendBuffer = Header & vbCrLf & ServerConnection(Index).Data
                ServerConnection(Index).DataSent = ServerConnection(Index).DataSent + Len(ServerConnection(Index).Data)
                ServerConnection(Index).Connected = True
                SendResponseHeader "Socket " & Index & " :" & vbCrLf & Header
                If DEBUG_MODE Then Debug.Print "send to client buffer " & vbCrLf & Header
            End If
        End If
    End Sub
    
    Private Sub sckClient_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
        'InitializeSocket sckClient(Index)
        'If Index <> 0 Then
            'ServerConnection(Index).ClearBuffer
        'End If
        
        InitializeSocket sckClient(Index)
        ClientConnection(Index).ClearBuffer
        If Index <> 0 Then
            Do While Len(ServerConnection(Index).SendBuffer) <> 0 Or sckServer(Index).State = sckClosed
                DoEvents
            Loop
            InitializeSocket sckServer(Index)
            ServerConnection(Index).ClearBuffer
        End If
    End Sub
    
    Private Sub sckServer_Close(Index As Integer)
        CloseSocket Index
    End Sub
    
    Private Sub sckServer_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    Dim i As Long, ActiveConnection As Long, ReceivingSocket As Winsock
        If Index = 0 Then
            ActiveConnection = 0
            For i = 0 To sckServer.Count - 1
                If i <> 0 Then If sckServer(i).State <> sckClosed Then ActiveConnection = ActiveConnection + 1
            Next i
            Set ReceivingSocket = AvailableSocket
            ReceivingSocket.Accept requestID
            If ActiveConnection < MaximumConnection Then
                SendMessage "Accept connection request from client " & AvailableSocket.RemoteHostIP & ":" & ReceivingSocket.RemotePort
            Else
                ServerConnection(ReceivingSocket.Index).Rejected = True
                SendMessage "Maximum connection reached, Connection request from client " & ReceivingSocket.RemoteHostIP & ":" & ReceivingSocket.RemotePort & " rejected"
            End If
        End If
        
        Set ReceivingSocket = Nothing
    End Sub
    
    Private Sub sckServer_DataArrival(Index As Integer, ByVal bytesTotal As Long)
    Dim i As Long, lpos As Long
    Dim vData As String
    Static Blocking As Boolean
    Dim Header As String
    
        If Index <> 0 And sckServer(Index).State = sckConnected Then
            sckServer(Index).GetData vData
            SendMessage "Receive data from client " & sckServer(Index).RemoteHostIP & ":" & sckServer(Index).RemotePort & " size: " & bytesTotal & " bytes"
            ClientConnection(Index).Append vData
            AppendLog Index, "From Client " & Index & " :" & vbCrLf & vData
            AddStatReceived sckServer(Index), Len(vData)
            
            If ClientConnection(Index).HeaderReceived And Not ClientConnection(Index).Connected Then
                If DEBUG_MODE Then Debug.Print "received from client " & vbCrLf & ClientConnection(Index).Header
                If ServerConnection(Index).Rejected Then
                    Header = GenerateHTMLForm(ftMaxReached)
                    ServerConnection(Index).SendBuffer = Header
                    SendResponseHeader "Socket " & Index & " :" & vbCrLf & Header
                    DoEvents
                    CloseSocket Index
                    If DEBUG_MODE Then Debug.Print "send to client buffer " & vbCrLf & Header
                ElseIf Not ServerConnection(Index).AuthorizeUser Then
                    ServerConnection(Index).AuthorizeUser = CheckCredential(sckServer(Index), ClientConnection(Index).Header)
                    If Not ServerConnection(Index).AuthorizeUser Then
                        Header = GenerateHTMLForm(ftAuthenticate)
                        ServerConnection(Index).SendBuffer = Header
                        SendResponseHeader "Socket " & Index & " :" & vbCrLf & Header
                        If DEBUG_MODE Then Debug.Print "send to client buffer " & vbCrLf & Header
                    Else
                        InitializeSocket sckClient(Index)
                        Header = FilterRequestHeader(ClientConnection(Index).Header)
                        ClientConnection(Index).SendBuffer = Header & vbCrLf & ClientConnection(Index).Data
                        ClientConnection(Index).DataSent = ClientConnection(Index).DataSent + Len(ClientConnection(Index).Data)
                        ClientConnection(Index).Connected = True
                        SendRequestHeader "Socket " & Index & " :" & vbCrLf & Header
                        AddConnectionStatistic sckServer(Index)
                        If DEBUG_MODE Then Debug.Print "send to server buffer " & vbCrLf & Header
                    End If
                ElseIf Left$(ClientConnection(Index).Header, 7) = "OPTIONS" Then
                    Header = GenerateHTMLForm(ftNotFound)
                    ServerConnection(Index).SendBuffer = Header
                    SendResponseHeader "Socket " & Index & " :" & vbCrLf & Header
                    DoEvents
                    CloseSocket Index
                Else
                    InitializeSocket sckClient(Index)
                    Header = FilterRequestHeader(ClientConnection(Index).Header)
                    ClientConnection(Index).SendBuffer = Header & vbCrLf & ClientConnection(Index).Data
                    ClientConnection(Index).DataSent = ClientConnection(Index).DataSent + Len(ClientConnection(Index).Data)
                    ClientConnection(Index).Connected = True
                    SendRequestHeader "Socket " & Index & " :" & vbCrLf & Header
                    AddConnectionStatistic sckServer(Index)
                    If DEBUG_MODE Then Debug.Print "send to server buffer " & vbCrLf & Header
                End If
            End If
        End If
    End Sub
    
    Private Sub sckServer_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
        CloseSocket Index
    End Sub
    to be continued....
    Last edited by blumoon; June 4th, 2013 at 11:34 AM. Reason: Resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center