通过监视发现传输中Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
ReDim Buff(1 To bytesTotal)
Winsock1.GetData Buff, vbByte
CopyMemory ShowBuff(Num + 1), Buff(1), bytesTotal
Num = Num + bytesTotal
End Sub会使得到的数据与发送数据不一致(数组错位)
建议重写该段代码
ReDim Buff(1 To bytesTotal)
Winsock1.GetData Buff, vbByte
CopyMemory ShowBuff(Num + 1), Buff(1), bytesTotal
Num = Num + bytesTotal
End Sub会使得到的数据与发送数据不一致(数组错位)
建议重写该段代码
解决方案 »
- 怎样设置控件焦点?
- 如何将文本框内容本末倒置?
- 如何让IE或webbrowser控件下载网页时,不下载flash?
- 怎样删除一条记录!!!!
- 有什么办法可以在处理这个问题?(关于焦点问题)
- 如何拷贝局域网的共享文件文件夹!
- 我使用AscB(LeftB("位", 1))取出的数值为77而实际应当为191,如何处理?
- 在VB中怎么调用CHM的格式帮助文件.
- 我想把label.caption 中的内容存到文档文件中,应当怎么做???十万火急!!!
- 关于winsock中close事件的问题
- 很简单的一个关于Combobox控件的问题
- 散分,请大家讨论用vb进行串口通信的问题,哪里有有用的资料,推荐一下.
(pDst As Any, pSrc As Any, ByVal ByteLen As Long)Private Const BI_RGB = 0&
Private Const DIB_RGB_COLORS = 0Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Private Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Private Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function CreateDIBSection Lib "gdi32" (ByVal hdc As Long, pBitmapInfo As BITMAPINFO, ByVal un As Long, ByVal lplpVoid As Long, ByVal handle As Long, ByVal dw As Long) As Long
Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFO, ByVal wUsage As Long) As Long
Private Declare Function SetDIBitsToDevice Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal Scan As Long, ByVal NumScans As Long, Bits As Any, BitsInfo As BITMAPINFO, ByVal wUsage As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject 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 Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As LongDim iBitmap As Long, IDC As Long
Dim bi24BitInfo As BITMAPINFO, bBytes() As Byte, Cnt As Long
Dim Num As Long, Buff() As Byte, ShowBuff() As Byte
Private Sub Form_Load()
With bi24BitInfo.bmiHeader
.biBitCount = 24
.biCompression = BI_RGB
.biPlanes = 1
.biSize = Len(bi24BitInfo.bmiHeader)
.biWidth = Screen.Width \ Screen.TwipsPerPixelX '15改为Screen.TwipsPerPixelX
.biHeight = Screen.Height \ Screen.TwipsPerPixelY '15改为Screen.TwipsPerPixelY
End With
ReDim ShowBuff(1 To bi24BitInfo.bmiHeader.biWidth * bi24BitInfo.bmiHeader.biHeight * 3) As Byte
ReDim bBytes(1 To bi24BitInfo.bmiHeader.biWidth * bi24BitInfo.bmiHeader.biHeight * 3) As Byte '24位色
IDC = CreateCompatibleDC(0)
iBitmap = CreateDIBSection(IDC, bi24BitInfo, DIB_RGB_COLORS, ByVal 0&, ByVal 0&, ByVal 0&)
SelectObject IDC, iBitmap
BitBlt IDC, 0, 0, bi24BitInfo.bmiHeader.biWidth, bi24BitInfo.bmiHeader.biHeight, GetDC(0), 0, 0, vbSrcCopy
GetDIBits IDC, iBitmap, 0, bi24BitInfo.bmiHeader.biHeight, bBytes(1), bi24BitInfo, DIB_RGB_COLORS
Winsock1.LocalPort = 5458
Winsock1.Bind 5458
Winsock1.Listen
Winsock2.RemoteHost = Winsock1.LocalIP
Winsock2.RemotePort = 5458
Winsock2.Connect Winsock2.RemoteHost, 5458
End SubPrivate Sub Command1_Click()
Num = 0
Winsock2.SendData bBytes
End SubPrivate Sub Command2_Click()
Me.Picture = LoadPicture("") SetDIBitsToDevice Me.hdc, 0, 0, bi24BitInfo.bmiHeader.biWidth, _
bi24BitInfo.bmiHeader.biHeight, 0, 0, 0, bi24BitInfo.bmiHeader.biHeight, _
ShowBuff(1), bi24BitInfo, DIB_RGB_COLORS
End SubPrivate Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
If Winsock1.State <> sckClosed Then Winsock1.Close
Winsock1.Accept requestID
End SubPrivate Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
ReDim Buff(1 To bytesTotal)
Winsock1.GetData Buff, vbByte
CopyMemory ShowBuff(Num + 1), Buff(0), bytesTotal 'Buff(1)改为Buff(0)
Num = Num + bytesTotal
End Sub
Case 1
.biSizeImage = (((.biWidth + 7) \ 8 + 3) And &HFFFFFFFC) * .biHeight
Case 4
.biSizeImage = (((.biWidth + 1) \ 2 + 3) And &HFFFFFFFC) * .biHeight
Case 8
.biSizeImage = ((.biWidth + 3) And &HFFFFFFFC) * .biHeight
Case 16
.biSizeImage = ((.biWidth * 2 + 3) And &HFFFFFFFC) * .biHeight
Case 24
.biSizeImage = ((.biWidth * 3 + 3) And &HFFFFFFFC) * .biHeight
Case 32
.biSizeImage = .biWidth * 4 * .biHeight
Case Else
Exit Function
End Select
Winsock1.GetData Buff, vbByte这一句向数组写入了内容,
怎么会没有Buff(0)?
这段写得很精彩,但只能单机运行。将它分开,它会在“ CopyMemory ShowBuff(Num + 1), Buff(0), bytesTotal 'Buff(1)改为Buff(0)
”这句出错!!!能将它改为真正可在网络运行的程序吗?
===============热切期望=============================================