API - CopyMemory [英] API - CopyMemory

查看:90
本文介绍了API - CopyMemory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用CopyMemory复制数组,如下所示:

Private Declare Sub CopyMemory Lib" kernel32"别名RtlMoveMemory (ByVal

pDst As Long,ByVal pSrc As Long,ByVal ByteLen as Integer)


dim kin(11)as Integer

dim kout(11)as Integer


kin(1)= 1''设置两个元素的值以查看Kout是否相同

kin( 5)= 5

CopyMemory(kout(0),kin(0),48)


它编译并运行但我得到的只是在Kout中,0表示0。所有元素。


-

休斯顿丹尼斯

I am trying to use CopyMemory to copy arrays as follows:

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal
pDst As Long, ByVal pSrc As Long, ByVal ByteLen As Integer)

dim kin(11) as Integer
dim kout(11) as Integer

kin(1)= 1 ''set values for two elements to see if Kout is the same
kin(5) = 5

CopyMemory(kout(0), kin(0), 48)

It compiles and runs but all I get in Kout is "0" for all elements.

--
Dennis in Houston

推荐答案

"丹尼斯" <德**** @ discussions.microsoft.com>在消息中写道

新闻:56 ********************************** @ microsof t.com ...
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:56**********************************@microsof t.com...
我正在尝试使用CopyMemory复制数组,如下所示:

私有声明Sub CopyMemory Lib" kernel32"别名RtlMoveMemory (ByVal
pDst As Long,ByVal pSrc As Long,ByVal ByteLen as Integer)

dim kin(11)as Integer
dim kout(11)as Integer

kin(1)= 1''设置两个元素的值以查看Kout是否相同
kin(5)= 5

CopyMemory(kout(0),kin (0),48)

它编译并运行,但我在Kout得到的只是0。对于所有元素。

-
Dennis in Houston
I am trying to use CopyMemory to copy arrays as follows:

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal
pDst As Long, ByVal pSrc As Long, ByVal ByteLen As Integer)

dim kin(11) as Integer
dim kout(11) as Integer

kin(1)= 1 ''set values for two elements to see if Kout is the same
kin(5) = 5

CopyMemory(kout(0), kin(0), 48)

It compiles and runs but all I get in Kout is "0" for all elements.

--
Dennis in Houston




尝试在API声明中将Long更改为Integer。看起来像VB6

声明。 VB6 Long = VB.Net整数


-

Al Reid



Try changing Long to Integer in the API declare. Looks like a VB6
declaration. VB6 Long = VB.Net Integer

--
Al Reid


试过,没有更改。我在网上找到了一个例子来计算复制数组的各种方法,即为vb.net写的循环,赋值和CopyMemory

。它不起作用,因为它只复制零。作者

显然没有通过在源数组中实际放置值来测试它。

-

Dennis in Houston

" Al Reid"写道:
Tried that, no change. I found an example on the web that timed the various
methods of copying arrays, i.e., for loop, assignment, and CopyMemory written
for vb.net. It doesn''t work either as it only copies zeros. The author
apparently didn''t test it by actually putting values in the source array.
--
Dennis in Houston
"Al Reid" wrote:
" Dennis" <德**** @ discussions.microsoft.com>在消息中写道
新闻:56 ********************************** @ microsof t.com。 ..
"Dennis" <De****@discussions.microsoft.com> wrote in message
news:56**********************************@microsof t.com...
我正在尝试使用CopyMemory复制数组,如下所示:

私有声明Sub CopyMemory Lib" kernel32"别名RtlMoveMemory (ByVal
pDst As Long,ByVal pSrc As Long,ByVal ByteLen as Integer)

dim kin(11)as Integer
dim kout(11)as Integer

kin(1)= 1''设置两个元素的值以查看Kout是否相同
kin(5)= 5

CopyMemory(kout(0),kin (0),48)

它编译并运行,但我在Kout得到的只是0。对于所有元素。

-
Dennis in Houston
I am trying to use CopyMemory to copy arrays as follows:

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal
pDst As Long, ByVal pSrc As Long, ByVal ByteLen As Integer)

dim kin(11) as Integer
dim kout(11) as Integer

kin(1)= 1 ''set values for two elements to see if Kout is the same
kin(5) = 5

CopyMemory(kout(0), kin(0), 48)

It compiles and runs but all I get in Kout is "0" for all elements.

--
Dennis in Houston



尝试在API声明中将Long更改为Integer。看起来像VB6
声明。 VB6 Long = VB.Net整数

- Al Reid



Try changing Long to Integer in the API declare. Looks like a VB6
declaration. VB6 Long = VB.Net Integer

--
Al Reid



Dennis写道:< br>
Dennis wrote:
试过,没有变化。我在网上找到了一个例子,它定时复制数组的各种方法,即为vb.net编写的for循环,赋值和CopyMemory。它不起作用,因为它只复制零。作者显然没有通过在源数组中实际放置值来测试它。
Tried that, no change. I found an example on the web that timed the various
methods of copying arrays, i.e., for loop, assignment, and CopyMemory written
for vb.net. It doesn''t work either as it only copies zeros. The author
apparently didn''t test it by actually putting values in the source array.



我会得到你应该通过ref而不是val但是。 ......


I would have the that you should be passing by ref not by val but ....


这篇关于API - CopyMemory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆