I m trying to send the content off the clipboard via the winsock
the pb.Contents = pct rturn a error Run-time error 5
any help will be appreciated
here is the code for the client and the server
Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_SNAPSHOT = &H2C
'..............................................................................
' Server
'...............................................................................
Private Sub cmdListen_Click()
Serversock.LocalPort = 1234
Serversock.Listen
End Sub
Private Sub Serversock_ConnectionRequest(ByVal requestID As Long)
If Serversock.State <> sckClosed Then
Serversock.Close
End If
Serversock.Accept requestID
Text1.Text = Text1.Text & "Accepted connection from: " & Serversock.RemoteHostIP & vbCrLf
End Sub
Private Sub Serversock_DataArrival(ByVal bytesTotal As Long)
Dim pb As New PropertyBag
Dim pct As Variant
Serversock.GetData pct
Set pb = New PropertyBag
pb.Contents = pct
Set Picture1.Picture = pb.ReadProperty("MyPicture")
Set pb = Nothing
End Sub
'..............................................................................
' Client
'...............................................................................
Private Sub cmdConnect_Click()
Clientsock.RemoteHost = "127.0.0.1"
Clientsock.RemotePort = 1234
Clientsock.Connect
End Sub
Private Sub cmdSend_Click()
Dim pb As PropertyBag
Dim pct As Variant
Set pb = New PropertyBag
' Press the Print Screen key
Clipboard.Clear
keybd_event vbKeySnapshot, 0, 0, 0
DoEvents
pb.WriteProperty "MyPicture", Clipboard.GetData(vbCFBitmap)
Clientsock.SendData pb.Contents
Set pb = Nothing
End Sub
the pb.Contents = pct rturn a error Run-time error 5
any help will be appreciated
here is the code for the client and the server
Option Explicit
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const VK_SNAPSHOT = &H2C
'..............................................................................
' Server
'...............................................................................
Private Sub cmdListen_Click()
Serversock.LocalPort = 1234
Serversock.Listen
End Sub
Private Sub Serversock_ConnectionRequest(ByVal requestID As Long)
If Serversock.State <> sckClosed Then
Serversock.Close
End If
Serversock.Accept requestID
Text1.Text = Text1.Text & "Accepted connection from: " & Serversock.RemoteHostIP & vbCrLf
End Sub
Private Sub Serversock_DataArrival(ByVal bytesTotal As Long)
Dim pb As New PropertyBag
Dim pct As Variant
Serversock.GetData pct
Set pb = New PropertyBag
pb.Contents = pct
Set Picture1.Picture = pb.ReadProperty("MyPicture")
Set pb = Nothing
End Sub
'..............................................................................
' Client
'...............................................................................
Private Sub cmdConnect_Click()
Clientsock.RemoteHost = "127.0.0.1"
Clientsock.RemotePort = 1234
Clientsock.Connect
End Sub
Private Sub cmdSend_Click()
Dim pb As PropertyBag
Dim pct As Variant
Set pb = New PropertyBag
' Press the Print Screen key
Clipboard.Clear
keybd_event vbKeySnapshot, 0, 0, 0
DoEvents
pb.WriteProperty "MyPicture", Clipboard.GetData(vbCFBitmap)
Clientsock.SendData pb.Contents
Set pb = Nothing
End Sub