我想实现类似这样c函数的功能
void cfunction(int startAddress, int length)
{
*(startAddress+length)=0x48;
}
而对应的vb函数:
外面有一个byte数组,现在要通过程序将该数组第length个元素置成0x80
private sub vbFunction(byval startAddress as byte, byval length as integer)end sub
函数体中间应怎么写呢?
void cfunction(int startAddress, int length)
{
*(startAddress+length)=0x48;
}
而对应的vb函数:
外面有一个byte数组,现在要通过程序将该数组第length个元素置成0x80
private sub vbFunction(byval startAddress as byte, byval length as integer)end sub
函数体中间应怎么写呢?
private sub vbFunction(byval startAddress as byte(), byval length as integer)
startAddress(length)=&h48 或 startAddress(length-1)=&h48
end sub
Private Sub vbFunction(ByVal startAddress As Byte, ByVal length As Integer)
Dim nValue As Integer
nValue = &H48
CopyMemory ByVal (startAddress + length), nValue, LenB(nValue)
End Sub
Private Sub vbFunction(startAddress As Byte, ByVal length As Integer)
Dim nValue As Integer
nValue = &H48
CopyMemory ByVal (VarPtr(startAddress) + length), nValue, LenB(nValue)
End Sub
我没试过 不行的话发消息给我
Dim nValue As Integer
nValue = &H48
CopyMemory ByVal (startAddress + length), nValue, 1
End SubPrivate Sub Form_Load()
Dim b(80) As Byte
vbFunction VarPtr(b(0)), 4
End Sub