VB 中的.Winsock 控件怎么传送图片
最好能给个例子.因为我是初学者.谢谢.PrivateDeclareFunctionGetDCLib"user32"(ByValhwndAsLong)AsLongPriva...
最好能给个例子.因为我是初学者.谢谢.
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal xSrc As Long, _
ByVal ySrc As Long, _
ByVal dwRop As Long) As Long
Private Sub Form_Load()
Dim lDesktop As Long
Dim lDC As Long
Form1.AutoRedraw = True
Form1.ScaleMode = 1
lDesktop = GetDesktopWindow() '取得桌面窗口
lDC = GetDC(lDesktop) '取得桌面窗口的设备场景
BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, lDC, 0, 0, vbSrcCopy '将桌面图象绘制到窗体
'Me.Top = 0
'Me.Left = 0
'Me.Width = Screen.Width
'Me.Height = Screen.Height
End Sub
这样能获取图片。可是怎么通过Winsock控件 来传送呢? 展开
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal nWidth As Long, _
ByVal nHeight As Long, _
ByVal hSrcDC As Long, _
ByVal xSrc As Long, _
ByVal ySrc As Long, _
ByVal dwRop As Long) As Long
Private Sub Form_Load()
Dim lDesktop As Long
Dim lDC As Long
Form1.AutoRedraw = True
Form1.ScaleMode = 1
lDesktop = GetDesktopWindow() '取得桌面窗口
lDC = GetDC(lDesktop) '取得桌面窗口的设备场景
BitBlt Me.hDC, 0, 0, Screen.Width, Screen.Height, lDC, 0, 0, vbSrcCopy '将桌面图象绘制到窗体
'Me.Top = 0
'Me.Left = 0
'Me.Width = Screen.Width
'Me.Height = Screen.Height
End Sub
这样能获取图片。可是怎么通过Winsock控件 来传送呢? 展开
2个回答
展开全部
BitBlt Picture1.hDC, 0, 0, Screen.Width, Screen.Height, lDC, 0, 0, vbSrcCopy '将桌面图象绘制到窗体
SavePicture Picture1.Image, "E:\a.bmp"'\\\\\\\\\\\\\\\\\\\\\\\\\
cli发送文件端
Dim B() As Byte
Dim I As Long
Open "E:\a.bmp" For Binary As #1 '以二进制方式打开文件
I = LOF(#1) '获取文件长度’该大小以字节为单位
ReDim B(I - 1) '用于为动态数组变量重新分配存储空间。
Get #1, , B '将一个已打开的磁盘文件读入一个变量之中。
Close #1
cli.SendData B ', vbByte '发送整个文件,字节方式
ser 接收文件端 每次只能接收8000多字节,要分多次接收
Private Sub ser_DataArrival(ByVal bytesTotal As Long)
dim Bf() as byte
ser.GetData bf(), vbByte + vbArray ' 接收文件
Dim l As Long
Open App.Path & "\a.bmp" For Binary As #1 '写收接收的文件'在写文件这前要删除文件 kill App.Path & "\a.bmp"
l = LOF(#1) '获取已接收文件的长度
If l> 0 Then Seek 1, l+ 1 '如果没有接收就重写,已接收有,就接着文件写入 'seek 在 Open 语句打开的文件中指定当前的读/写位置。
Put #1, , bf'接着写入文件
Close #1
End Sub
Form1.Picture = LoadPicture(App.Path & "\a.bmp")
SavePicture Picture1.Image, "E:\a.bmp"'\\\\\\\\\\\\\\\\\\\\\\\\\
cli发送文件端
Dim B() As Byte
Dim I As Long
Open "E:\a.bmp" For Binary As #1 '以二进制方式打开文件
I = LOF(#1) '获取文件长度’该大小以字节为单位
ReDim B(I - 1) '用于为动态数组变量重新分配存储空间。
Get #1, , B '将一个已打开的磁盘文件读入一个变量之中。
Close #1
cli.SendData B ', vbByte '发送整个文件,字节方式
ser 接收文件端 每次只能接收8000多字节,要分多次接收
Private Sub ser_DataArrival(ByVal bytesTotal As Long)
dim Bf() as byte
ser.GetData bf(), vbByte + vbArray ' 接收文件
Dim l As Long
Open App.Path & "\a.bmp" For Binary As #1 '写收接收的文件'在写文件这前要删除文件 kill App.Path & "\a.bmp"
l = LOF(#1) '获取已接收文件的长度
If l> 0 Then Seek 1, l+ 1 '如果没有接收就重写,已接收有,就接着文件写入 'seek 在 Open 语句打开的文件中指定当前的读/写位置。
Put #1, , bf'接着写入文件
Close #1
End Sub
Form1.Picture = LoadPicture(App.Path & "\a.bmp")
参考资料: http://hi.baidu.com/bl5wb/blog/item/ac339b6e321254d880cb4adb.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询