📄 socket.ctl
字号:
VERSION 5.00
Begin VB.UserControl Socket
CanGetFocus = 0 'False
ClientHeight = 420
ClientLeft = 0
ClientTop = 0
ClientWidth = 420
InvisibleAtRuntime= -1 'True
Picture = "Socket.ctx":0000
ScaleHeight = 28
ScaleMode = 3 'Pixel
ScaleWidth = 28
ToolboxBitmap = "Socket.ctx":0972
End
Attribute VB_Name = "Socket"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'****************************************************************************
'人人为我,我为人人
'枕善居汉化收藏整理
'发布日期:2007/08/12
'描 述:利用VNC控制和查看局域网用户屏幕 V0.2 (稳定beta版)
'网 站:http://www.Mndsoft.com/ (VB6源码博客)
'网 站:http://www.VbDnet.com/ (VB.NET源码博客,主要基于.NET2005)
'e-mail :Mndsoft@163.com
'e-mail :Mndsoft@126.com
'OICQ :88382850
' 如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************
Option Explicit
'Don't forget to change CSocketMaster class
'instancing property to PublicNotCreatable
'These are the same events CSocket has
'Public Event CloseSck()
'Public Event Connect()
'Public Event ConnectionRequest(ByVal requestID As Long)
'Public Event DataArrival(ByVal bytesTotal As Long)
'Public Event Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
'Public Event SendComplete()
'Public Event SendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)
Public Event OnClose()
Public Event OnConnect()
Public Event OnConnectionRequest(ByVal requestID As Long)
Public Event OnDataArrival(ByVal bytesTotal As Long)
Public Event OnError(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Public Event OnSendComplete()
Public Event OnSendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)
'Our socket
Private WithEvents cmSocket As CSocket
Attribute cmSocket.VB_VarHelpID = -1
Private Sub UserControl_Initialize()
'create an instance of CSocketMaster
Set cmSocket = New CSocket
End Sub
Private Sub UserControl_Terminate()
'destroy instance of CSocketMaster
Set cmSocket = Nothing
End Sub
Private Sub UserControl_Resize()
'this is used to lock control size
UserControl.Width = 420
UserControl.Height = 420
End Sub
'Control properties. Every time the control is built
'the class instance cmSocket is reset, and so the
'control properties. We use these variables to make
'control properties persistent.
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
Me.LocalPort = PropBag.ReadProperty("LocalPort", 0)
Me.Protocol = PropBag.ReadProperty("Protocol", 0)
Me.RemoteHost = PropBag.ReadProperty("RemoteHost", "")
Me.RemotePort = PropBag.ReadProperty("RemotePort", 0)
Me.Tag = PropBag.ReadProperty("Tag", "")
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
PropBag.WriteProperty "LocalPort", Me.LocalPort, 0
PropBag.WriteProperty "Protocol", Me.Protocol, 0
PropBag.WriteProperty "RemoteHost", Me.RemoteHost, ""
PropBag.WriteProperty "RemotePort", Me.RemotePort, 0
PropBag.WriteProperty "Tag", Me.Tag, ""
End Sub
'From this point we declare all the 'bridge' function
'and properties. The idea is very simple, when user
'call a function we call cmSocket function, when
'cmSocket raises an event we raise an event, when user
'set a property we set cmSocket property, when user
'retrieves a property we retrieve cmSocket property
'and pass the result to user.
'Easy, isn't it?
Private Sub cmSocket_OnClose()
RaiseEvent OnClose
End Sub
'Private Sub cmSocket_CloseSck()
'RaiseEvent CloseSck
'End Sub
Private Sub cmSocket_onConnect()
RaiseEvent OnConnect
End Sub
Private Sub cmSocket_onConnectionRequest(ByVal requestID As Long)
RaiseEvent OnConnectionRequest(requestID)
End Sub
Private Sub cmSocket_onDataArrival(ByVal bytesTotal As Long)
RaiseEvent OnDataArrival(bytesTotal)
End Sub
Private Sub cmSocket_onError(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
RaiseEvent OnError(Number, Description, Scode, Source, HelpFile, HelpContext, CancelDisplay)
End Sub
Private Sub cmSocket_onSendComplete()
RaiseEvent OnSendComplete
End Sub
Private Sub cmSocket_onSendProgress(ByVal bytesSent As Long, ByVal bytesRemaining As Long)
RaiseEvent OnSendProgress(bytesSent, bytesRemaining)
End Sub
Public Property Get RemotePort() As Long
Attribute RemotePort.VB_Description = "Returns/Sets the port to be connected to on the remote computer"
RemotePort = cmSocket.RemotePort
End Property
Public Property Let RemotePort(ByVal lngPort As Long)
cmSocket.RemotePort = lngPort
End Property
Public Property Get RemoteHost() As String
Attribute RemoteHost.VB_Description = "Returns/Sets the name used to identify the remote computer"
RemoteHost = cmSocket.RemoteHost
End Property
Public Property Let RemoteHost(ByVal strHost As String)
cmSocket.RemoteHost = strHost
End Property
Public Property Get RemoteHostIP() As String
RemoteHostIP = cmSocket.RemoteHostIP
End Property
Public Property Get LocalPort() As Long
Attribute LocalPort.VB_Description = "Returns/Sets the port used on the local computer"
LocalPort = cmSocket.LocalPort
End Property
Public Property Let LocalPort(ByVal lngPort As Long)
cmSocket.LocalPort = lngPort
End Property
Public Property Get State() As StateConstants
State = cmSocket.State
End Property
Public Property Get LocalHostName() As String
LocalHostName = cmSocket.LocalHostName
End Property
Public Property Get LocalIP() As String
LocalIP = cmSocket.LocalIP
End Property
Public Property Get BytesReceived() As Long
BytesReceived = cmSocket.BytesReceived
End Property
Public Property Get SocketHandle() As Long
SocketHandle = cmSocket.SocketHandle
End Property
Public Property Get Tag() As String
Tag = cmSocket.Tag
End Property
Public Property Let Tag(ByVal strTag As String)
Attribute Tag.VB_Description = "Returns or sets an expression that stores any extra data needed for your program"
cmSocket.Tag = strTag
End Property
Public Property Get Protocol() As ProtocolConstants
Protocol = cmSocket.Protocol
End Property
Public Property Let Protocol(ByVal enmProtocol As ProtocolConstants)
Attribute Protocol.VB_Description = "Returns/Sets the socket protocol"
cmSocket.Protocol = enmProtocol
End Property
Public Sub Accept(requestID As Long)
cmSocket.Accept requestID
End Sub
Public Sub Bind(Optional LocalPort As Variant, Optional LocalIP As Variant)
cmSocket.Bind LocalPort, LocalIP
End Sub
Public Sub CloseSocket()
cmSocket.CloseSocket
End Sub
Public Sub Connect(Optional RemoteHost As Variant, Optional RemotePort As Variant)
cmSocket.Connect RemoteHost, RemotePort
End Sub
Public Sub GetData(ByRef data As Variant, Optional varType As Variant, Optional maxLen As Variant)
cmSocket.GetData data, varType, maxLen
End Sub
Public Sub Listen()
cmSocket.Listen
End Sub
Public Sub PeekData(ByRef data As Variant, Optional varType As Variant, Optional maxLen As Variant)
cmSocket.PeekData data, varType, maxLen
End Sub
Public Sub SendData(data As Variant)
cmSocket.SendData data
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -