Advertisement
RyanDaCoder

x/z

Sep 21st, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. 'SERVER
  2. Option Explicit On
  3. Imports System.IO
  4.  
  5. Imports System.Net.Sockets
  6. Imports System.Threading
  7. Imports System.Drawing
  8. Imports System.Runtime.Serialization.Formatters.Binary
  9. Public Class Form1
  10. Dim TimerEnabled
  11. Dim Clienty As TcpClient
  12. Dim client As New TcpClient
  13. Dim port As Integer
  14. Dim server As TcpListener
  15. Dim ns As NetworkStream
  16. Dim listening As New Thread(AddressOf Listen)
  17. Dim getimage As New Thread(AddressOf RecieveImage)
  18.  
  19. Private Sub RecieveImage()
  20. Dim bf As New BinaryFormatter
  21. While client.Connected = True
  22. Try
  23. ns = client.GetStream
  24. PictureBox1.Image = bf.Deserialize(ns)
  25. Catch ex As Exception
  26. PictureBox1.Image = Nothing
  27. End Try
  28. End While
  29. End Sub
  30.  
  31. Private Sub Listen()
  32. While client.Connected = False
  33. server.Start()
  34. client = server.AcceptTcpClient
  35. End While
  36. getimage.Start()
  37. End Sub
  38.  
  39. Private Sub ScreenMonitoring_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  40. port = Integer.Parse(Form1.TextBox1.Text)
  41. server = New TcpListener(port)
  42. listening.Start()
  43. End Sub
  44. End Class
  45.  
  46.  
  47.  
  48.  
  49.  
  50. 'CLIENT
  51. Imports System.Net.Sockets
  52. Imports System.Threading
  53. Imports System.Drawing
  54. Imports System.Runtime.Serialization.Formatters.Binary
  55.  
  56. Public Class Form1
  57.  
  58. Dim client As New TcpClient
  59. Dim ns As NetworkStream
  60. Dim port As Integer
  61.  
  62. Public Function GetDesktop() As Image
  63. Dim bounds As Rectangle = Nothing
  64. Dim Screenshot As System.Drawing.Bitmap = Nothing
  65. Dim Graph As Graphics = Nothing
  66. bounds = Screen.PrimaryScreen.Bounds
  67. Screenshot = New Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
  68. Graph = Graphics.FromImage(Screenshot)
  69. Graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
  70. Return Screenshot
  71. End Function
  72.  
  73. Private Sub SendDesktop()
  74. Dim bf As New BinaryFormatter
  75. ns = client.GetStream
  76. bf.Serialize(ns, GetDesktop())
  77.  
  78. End Sub
  79.  
  80. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  81. SendDesktop()
  82. End Sub
  83.  
  84.  
  85. Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  86. Try
  87. port = Integer.Parse(TextBox2.Text)
  88. Try
  89. client.Connect(TextBox1.Text, port)
  90. Timer1.Start()
  91. Catch ex As Exception
  92.  
  93. End Try
  94. Catch ex As Exception
  95.  
  96. End Try
  97. End Sub
  98.  
  99. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  100.  
  101. End Sub
  102. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement