本文介绍了copymem API存在问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我使用以下代码 私有var1为长 私有var2为长 私有var3为长 ReDim bytearray(0到3) ReDim bytearray2(0到3) 对于a = 0 To 3 bytearray(a)= Asc(Mid(DataSource,b,1)) bytearray2(a)= Asc(Mid(DataSource2,c,1)) b = b + 1 c = c + 1 下一页 var1 = IVbytearray(0 )& IVbytearray(1)& IVbytearray(2)& IVbytearray(3) var2 = IVbytearray2(0)& IVbytearray2(1)& IVbytearray2(2)& IVbytearray2(3) CopyMemory var1,var1 Xor var2,4 CopyMemory var1,var1 Xor var3,4 一个溢出错误有时会在copymemory api中被抛出,我该如何修复 呢? 解决方案 我无法理解这段代码 - 你不能使用&用于建立一个字节长的空间 如果你描述了你想要做的事情,那么也许我们可以提出建议的。 我无法理解这段代码 - 你不能使用&用于建立一个字节长的空间 如果你描述了你想要做的事情,那么也许我们可以提出建议的。 这些是多余的它们在下一个块中被替换。 这会将UNICODE字符串复制到字节数组中。 Th将是16个字节,每隔一个是一个空字符。 如果你想将每个字符作为数组中的项目,那么你想要: bytearray = StrConv(string,vbFromUnicode) 从下面的代码中,你不能像这样加入它们。 你需要手动进行算术运算并添加)或 copymemory从字节数组到一个长。 请记住,你只能在一个长的4个字节... 调用CopyMemory(var1,var1 Xor var2,8) 调用CopyMemory(var1,var1 Xor var3,8) 非常小心,因为多数只剩下4个字节。 你将使用这段代码破坏内存。 在 结束时,它仍然没有解释你有什么以及你想要的结果...... - Dean Earley(de*********@icode.co.uk) i-Catcher开发团队 iCode Systems i am using the following code private var1 as Longprivate var2 as Longprivate var3 as Long ReDim bytearray(0 To 3)ReDim bytearray2(0 To 3) For a = 0 To 3bytearray(a) = Asc(Mid(DataSource, b, 1))bytearray2(a) = Asc(Mid(DataSource2, c, 1))b = b + 1c = c + 1Next a var1 = IVbytearray(0) & IVbytearray(1) & IVbytearray(2) & IVbytearray(3)var2 = IVbytearray2(0) & IVbytearray2(1) & IVbytearray2(2) & IVbytearray2(3) CopyMemory var1, var1 Xor var2, 4CopyMemory var1, var1 Xor var3, 4 an overflow error is sometimes thrown up in the copymemory api, how do i fixit? 解决方案 I can''t make any sense of this code- you don''t use & for building a Long out of Bytes If you described what you are trying to do, then maybe we can come upwith a suggestion. I can''t make any sense of this code- you don''t use & for building a Long out of BytesIf you described what you are trying to do, then maybe we can come upwith a suggestion. These are redundant as they are replaced in the next block. This copies a UNICODE string into the byte array.This will be 16 bytes, every other one being a null character. If you want each character as an item in the array, then you want:bytearray = StrConv(string, vbFromUnicode) From the code below, you can''t join them up like this.You will need to do the arithmetic manually (shifting and adding) orcopymemory from the byte array to a long.Bear in mind that you can only fit 4 bytes in a long... Be VERY careful as longs are still only 4 bytes.you WILL be corrupting memory with this code. It still doesn''t explain what you have and what results you want at theend... --Dean Earley (de*********@icode.co.uk)i-Catcher Development Team iCode Systems 这篇关于copymem API存在问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 11:12