How to make a Desktop viewer vb 2010~!
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
First Make two projects! One for Client and One for Server.
Name them what ever you want.
Get to your client project.
Objects needed-
1 picturebox(mine is named picDesk)
2 textboxes for ports(first textbox is txtport and second one is txtport2
1 button(mine is named btnListen)
after that you will need to import these settings-
Now go to your server project.
Objects needed-
3 textboxes(textbox1 for me is for ip address and is named(txtIp) textbox2 for me is for the first port # i named it(txtport) and (txtport2 for the second one)
1button- mine is named btnConnect
that is all needed now for the coding part.
import these settings-
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Net.Sockets
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Threading
make sub named New() like in the client-
Put this code in the button_click event
That is how to make a Desktop viewer, thanks for reading!
Name them what ever you want.
Get to your client project.
Objects needed-
1 picturebox(mine is named picDesk)
2 textboxes for ports(first textbox is txtport and second one is txtport2
1 button(mine is named btnListen)
after that you will need to import these settings-
Code: Select all
after that make a new sub called New or just copy below .
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Net.Sockets
Imports System.Net
Imports System.Threading
Imports System.Runtime.Serialization.Formatters.Binary
Code: Select all
Now for the listening main part to listen for the server.(put this below the New sub)
Public Sub New()
InitializeComponent()
CheckForIllegalCrossThreadCalls = False
End Sub
Code: Select all
Make a new sub, or for the listening part, just copy below and paste below Private funtions.
Private listener As TcpListener
Private imgListener As TcpListener
Private client As TcpClient
Private imgClient As TcpClient
Private imageListenThread As Thread
Private listenerThread As Thread
Code: Select all
This next code is for recieving constant images from the server and putting them onto the picturebox- Private Sub Listen()
listener = New TcpListener(IPAddress.Any, Integer.Parse(txtport.Text))
listener.Start()
'Starts listening for connections.
While True
client = listener.AcceptTcpClient()
'After it gets accepted, it breaks the loop since we don't need it anymore.
Exit While
End While
lblConnected.Text = "Connected: " & client.Client.RemoteEndPoint.ToString()
imageListenThread = New Thread(AddressOf imageListen)
imageListenThread.Start()
End Sub
Code: Select all
Now for the final part of making the Client, this is the button code, obviously it just starts subs, and private functions.
Private Sub imageListen()
imgListener = New TcpListener(IPAddress.Any, Integer.Parse(txtport2.Text))
imgListener.Start()
'Starts the imgListener.
While True
imgClient = imgListener.AcceptTcpClient()
'Same like above.
Exit While
End While
Dim formatter As New BinaryFormatter()
While True
'Starts the loop.
Using stream As NetworkStream = imgClient.GetStream()
'We're using the stream the image is serialized-
'to.
While True
'Gets the image and loops.
picDesk.Image = DirectCast(formatter.Deserialize(stream), Image)
End While
End Using
End While
End Sub
Code: Select all
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ listenerThread = New Thread(AddressOf Listen)
listenerThread.Start()
Now go to your server project.
Objects needed-
3 textboxes(textbox1 for me is for ip address and is named(txtIp) textbox2 for me is for the first port # i named it(txtport) and (txtport2 for the second one)
1button- mine is named btnConnect
that is all needed now for the coding part.
import these settings-
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports System.Net.Sockets
Imports System.Runtime.Serialization.Formatters.Binary
Imports System.Threading
make sub named New() like in the client-
Code: Select all
after that we need to put in the private functions to make variables and so on.
Public Sub New()
InitializeComponent()
End Sub
Code: Select all
Now make a sub called Send().
Private client As TcpClient
Private imgSender As TcpClient
Private senderThread As Thread
Public Function CaptureDesktop() As Image
Dim bounds As Rectangle = Nothing
Dim screenshot As System.Drawing.Bitmap = Nothing
Dim graph As Graphics = Nothing
bounds = Screen.PrimaryScreen.Bounds
screenshot = New Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
Return screenshot
End Function
Code: Select all
Oh course this is how the program sends the screen.Private Sub Send()
'You should know what this means from part 1, just in reverse.
imgSender = New TcpClient(txtIp.Text, Integer.Parse(txtPort2.Text))
Dim formatter As New BinaryFormatter()
While True
Using stream As NetworkStream = imgSender.GetStream()
While True
formatter.Serialize(stream, CaptureDesktop())
'So it doesn't kill the cpu.
Thread.Sleep(1)
End While
End Using
End While
End Sub
Put this code in the button_click event
Code: Select all
Try
client = New TcpClient(txtIp.Text, Integer.Parse(txtPort.Text))
senderThread = New Thread(AddressOf Send)
senderThread.Start()
Catch ex As Exception
'If it can't connect.
MessageBox.Show(ex.Message) ' telling if it cant get to the client.
End Try
That is how to make a Desktop viewer, thanks for reading!
------------------------------------------------------------------------------
Proprogrammer, not just a Programmer.
Proprogrammer, not just a Programmer.
Explain what it really does... You know Desktop Viewer doesn't explains much!
This is like remote control software, only you can just view the screen.
You don't need to have listener.AcceptTcpClient() in a while loop as the thread is blocked by this function already.
You don't need to have listener.AcceptTcpClient() in a while loop as the thread is blocked by this function already.
oh thanks mandai! Yeah this is like the application Team Viewer kinda.
------------------------------------------------------------------------------
Proprogrammer, not just a Programmer.
Proprogrammer, not just a Programmer.
so how do u use it.. ? never used team viewer before, infact lol never heard of it
Now I know it, So all this software does is that it displays another computer's screen on my computer!
Yeah pretty cool though for something if you want to give someone a tutorial! With Exceptionally Great QUALITY!
------------------------------------------------------------------------------
Proprogrammer, not just a Programmer.
Proprogrammer, not just a Programmer.
Well this looks nice. Will try it out later!!!
Instead of LOL use this -
LSIBMHBIWFETALOL
Which means -
Laughing silently in between my head because it wasn't funny enough to actually laugh out loud!
LSIBMHBIWFETALOL
Which means -
Laughing silently in between my head because it wasn't funny enough to actually laugh out loud!
So we just type in the port and we can speak and send images to each other?
In that case use port 150! So all can talk together.
Err, what IP should i type in? My?
In that case use port 150! So all can talk together.
Err, what IP should i type in? My?
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!
![Image]()
![Image]()
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;
Over 30 projects with source code!
Please give reputation to helpful members!

Copyright Information
Copyright © Codenstuff.com 2020 - 2023