Hi,
I was looking trough google play and found an app with wich i could remoteley perform shutdown commands on my computer. I had to run a server on the computer wich was provided by the author.
I wanted to create my own server. The app on my phone sends commands to the server on port 3000 ( default, can be changed ) and i listen on port 3000 with the server.
Well the problem is that the data comes in good but i cant do anything with it.
I tryed to put the incoming data in a string and then check it with an if statement but it just wont work. I now have set it up so that the data comes into a listbox and a timer checks the first item for a command. This also wont work. Im getting pretty frustrated about it and i hope somebody can help me.
My code:
Thanks in advance,Code:Private Sub c_ConnectionRequest(ByVal requestID As Long) 'accept connection If c.State <> sckClosed Then c.Close c.Accept requestID End Sub Private Sub c_DataArrival(ByVal bytesTotal As Long) 'get data Dim henk As String c.GetData henk List1.AddItem henk 'the data is added properly to the listbox 'just need to read it out properly. End Sub Private Sub Form_Load() c.Listen End Sub Private Sub Form_OLESetData(Data As DataObject, DataFormat As Integer) 'dont mind this sub, it is to store the if statements temporarely. If List1.List = "2:300" Then 'shutdown 5 minutes Label1.Caption = "Shutdown 5 minutes" End If If List1.List = "2:900" Then 'shutdown 15 minutes Label1.Caption = "Shutdown 15 minutes" End If If List1.List = "2:1800" Then 'shutdown 30 minutes Label1.Caption = "Shutdown 30 minutes" End If If List1.List = "2:3600" Then 'shutdown 1 hour Label1.Caption = "Shutdown 1 hour" End If If List1.List = "1:0" Then 'reboot Label1.Caption = "Reboot" End If If List1.List = "3:0" Then 'lock Label1.Caption = "Lock" End If If List1.List = "5:0" Then 'standby Label1.Caption = "Standby" End If If List1.List = "6:0" Then 'logoff Label1.Caption = "LogOff" End If End Sub Private Sub Timer1_Timer() 'timer to check if there is a connection with the client If Not c.State = 7 Then Form1.Caption = "No connection!" Else Form1.Caption = "Connection established" End If End Sub Private Sub Timer2_Timer() 'this is the timer that checks the listbox If List1.ListCount = 0 Then Exit Sub End If If List1.List(1) = "2:0" Then 'shutdown Label1.Caption = "Shutdown" MsgBox "shutdown" List1.RemoveItem 0 Else List1.RemoveItem 0 End If End Sub
Jason8100




Reply With Quote