小弟用winsock做一个自定义数组的发送,代码如下:
发送端:
Option Explicit
Type sendpack
cpu_temperature As String
ups_state As String
x_laser_intensity As String
y_laser_intensity As String
x_temperature As String
End Type
Dim sp() As Byte, sendp As sendpackPublic Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" ( _
hpvDest As Any, hpvSource As Any, ByVal cbCop)Public Sub cmsg_pack_send()sendp.cpu_temperature = Form1.Text3.Text
sendp.ups_state = Form1.Text5.Text
sendp.x_laser_intensity = Form1.Text6.Text
sendp.y_laser_intensity = Form1.Text7.Text
sendp.x_temperature = Form1.Text8.Text ReDim sp(LenB(sendp) - 1) As Byte
CopyMemory sp(0), sendp, LenB(sendp)
Form1.Winsock1.senddata spEnd Sub然后程序运行时出错,如下提示
实时错误 49
dll 调用约定错误错误行显示在 CopyMemory sp(0), sendp, LenB(sendp) 上
请各位大哥帮帮看看啥问题啊,谢谢了!
发送端:
Option Explicit
Type sendpack
cpu_temperature As String
ups_state As String
x_laser_intensity As String
y_laser_intensity As String
x_temperature As String
End Type
Dim sp() As Byte, sendp As sendpackPublic Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" ( _
hpvDest As Any, hpvSource As Any, ByVal cbCop)Public Sub cmsg_pack_send()sendp.cpu_temperature = Form1.Text3.Text
sendp.ups_state = Form1.Text5.Text
sendp.x_laser_intensity = Form1.Text6.Text
sendp.y_laser_intensity = Form1.Text7.Text
sendp.x_temperature = Form1.Text8.Text ReDim sp(LenB(sendp) - 1) As Byte
CopyMemory sp(0), sendp, LenB(sendp)
Form1.Winsock1.senddata spEnd Sub然后程序运行时出错,如下提示
实时错误 49
dll 调用约定错误错误行显示在 CopyMemory sp(0), sendp, LenB(sendp) 上
请各位大哥帮帮看看啥问题啊,谢谢了!
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
最后一个参数没有指定数据类型。