Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'SERVER
- Option Explicit On
- Imports System.IO
- Imports System.Net.Sockets
- Imports System.Threading
- Imports System.Drawing
- Imports System.Runtime.Serialization.Formatters.Binary
- Public Class Form1
- Dim TimerEnabled
- Dim Clienty As TcpClient
- Dim client As New TcpClient
- Dim port As Integer
- Dim server As TcpListener
- Dim ns As NetworkStream
- Dim listening As New Thread(AddressOf Listen)
- Dim getimage As New Thread(AddressOf RecieveImage)
- Private Sub RecieveImage()
- Dim bf As New BinaryFormatter
- While client.Connected = True
- Try
- ns = client.GetStream
- PictureBox1.Image = bf.Deserialize(ns)
- Catch ex As Exception
- PictureBox1.Image = Nothing
- End Try
- End While
- End Sub
- Private Sub Listen()
- While client.Connected = False
- server.Start()
- client = server.AcceptTcpClient
- End While
- getimage.Start()
- End Sub
- Private Sub ScreenMonitoring_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- port = Integer.Parse(Form1.TextBox1.Text)
- server = New TcpListener(port)
- listening.Start()
- End Sub
- End Class
- 'CLIENT
- Imports System.Net.Sockets
- Imports System.Threading
- Imports System.Drawing
- Imports System.Runtime.Serialization.Formatters.Binary
- Public Class Form1
- Dim client As New TcpClient
- Dim ns As NetworkStream
- Dim port As Integer
- Public Function GetDesktop() 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.Format32bppPArgb)
- Graph = Graphics.FromImage(Screenshot)
- Graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
- Return Screenshot
- End Function
- Private Sub SendDesktop()
- Dim bf As New BinaryFormatter
- ns = client.GetStream
- bf.Serialize(ns, GetDesktop())
- End Sub
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- SendDesktop()
- End Sub
- Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Try
- port = Integer.Parse(TextBox2.Text)
- Try
- client.Connect(TextBox1.Text, port)
- Timer1.Start()
- Catch ex As Exception
- End Try
- Catch ex As Exception
- End Try
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement