如何声明一个庞大的字节数组 [英] How to declare a pointerto an array of bytes

查看:86
本文介绍了如何声明一个庞大的字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从C#程序调用VerQueryValue。 VerQueryValue将其作为其参数之一的指针指向一个指向字节数组的指针,它使用
来返回指向所需数组的指针。现在,我可以这样称呼:

byte * lpBuffer;

int length;

string subBlock = @" \StringFileInfo \\ \\" + langCodePage +

@" \FileDescription" ;;

result = VerQueryValue(buffer,subBlock,& lpBuffer,& length);

然后我没有一个byte []传递给ASCIEncoding对象进行解码。

我真正想做的是声明

byte [] * lplpBuffer

然后将其传递给VerQueryValue,但C#显然不允许这样做。

(奇怪的是,如果我宣布

字节[] lpBuffer;

我收到错误无法从byte [] *转换为字节**,这很奇怪如果

它无法识别字节[] *作为一种类型无论如何)

任何人都可以放弃任何光线吗?

-

Dave

I am trying to call VerQueryValue from a C# program. VerQueryValue takes as
one of its parameters a pointer to a pointer to an array of bytes, which it
uses to return a pointer to the required array. Now, I can call it like this:
byte* lpBuffer;
int length;
string subBlock = @"\StringFileInfo\" + langCodePage +
@"\FileDescription";
result = VerQueryValue(buffer, subBlock, &lpBuffer, &length);
but then I don''t have a byte[] to pass to an ASCIEncoding object to decode.
What I really want to do is declare
byte[]* lplpBuffer
and then pass that to VerQueryValue, but C# apparently won''t allow that.
(Oddly enough if I declare
byte[] lpBuffer;
I get an error "cannot convert from byte[]* to byte**", which is peculiar if
it doesn''t recognise byte[]* as a type anyway)
Can anyone shed any light?
--
Dave

推荐答案



" Dave" <沓** @ discussions.microsoft.com>在消息中写道

新闻:E9 ********************************** @ microsof t.com ...

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:E9**********************************@microsof t.com...
我试图从C#程序调用VerQueryValue。 VerQueryValue将其作为其参数之一的指针指向指向字节数组的指针,该指针用于返回指向所需数组的指针。现在,我可以称之为
这个:
byte * lpBuffer;
int length;
string subBlock = @" \StringFileInfo \" + langCodePage +
@" \FileDescription" ;;
result = VerQueryValue(buffer,subBlock,& lpBuffer,& length);
但是我没有一个字节[]传递给ASCIEncoding对象进行解码。
我真正要做的是声明
byte [] * lplpBuffer
然后将它传递给VerQueryValue,但C#显然不允许这样。
(奇怪的是,如果我声明
byte [] lpBuffer;
我收到错误无法从byte [] *转换为byte **,这是奇特的
如果
它无法识别byte [] *作为一种类型)
任何人都可以放弃任何光线吗?
-
戴夫
I am trying to call VerQueryValue from a C# program. VerQueryValue takes as
one of its parameters a pointer to a pointer to an array of bytes, which
it
uses to return a pointer to the required array. Now, I can call it like
this:
byte* lpBuffer;
int length;
string subBlock = @"\StringFileInfo\" + langCodePage +
@"\FileDescription";
result = VerQueryValue(buffer, subBlock, &lpBuffer, &length);
but then I don''t have a byte[] to pass to an ASCIEncoding object to
decode.
What I really want to do is declare
byte[]* lplpBuffer
and then pass that to VerQueryValue, but C# apparently won''t allow that.
(Oddly enough if I declare
byte[] lpBuffer;
I get an error "cannot convert from byte[]* to byte**", which is peculiar
if
it doesn''t recognise byte[]* as a type anyway)
Can anyone shed any light?
--
Dave




无需使用指针,通过引用传递byte []:


byte [] lpBuffer;

VerQueryValue(....,ref lpBuffer,...);


Willy。



No need to use pointers, pass the byte[] by reference:

byte[] lpBuffer;
VerQueryValue(...., ref lpBuffer,...);

Willy.


''Fraid不!这使得无法从''转换字节[]''转换为''字节**''

-

戴夫

Willy Denoyette [MVP]"写道:
''Fraid not! That gives "cannot convert from ''ref byte[]'' to ''byte**''
--
Dave
"Willy Denoyette [MVP]" wrote:

戴夫 <沓** @ discussions.microsoft.com>在消息中写道
新闻:E9 ********************************** @ microsof t.com。 ..

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:E9**********************************@microsof t.com...
我试图从C#程序调用VerQueryValue。 VerQueryValue将其作为其参数之一的指针指向指向字节数组的指针,该指针用于返回指向所需数组的指针。现在,我可以称之为
这个:
byte * lpBuffer;
int length;
string subBlock = @" \StringFileInfo \" + langCodePage +
@" \FileDescription" ;;
result = VerQueryValue(buffer,subBlock,& lpBuffer,& length);
但是我没有一个字节[]传递给ASCIEncoding对象进行解码。
我真正要做的是声明
byte [] * lplpBuffer
然后将它传递给VerQueryValue,但C#显然不允许这样。
(奇怪的是,如果我声明
byte [] lpBuffer;
我收到错误无法从byte [] *转换为byte **,这是奇特的
如果
它无法识别byte [] *作为一种类型)
任何人都可以放弃任何光线吗?
-
戴夫
I am trying to call VerQueryValue from a C# program. VerQueryValue takes as
one of its parameters a pointer to a pointer to an array of bytes, which
it
uses to return a pointer to the required array. Now, I can call it like
this:
byte* lpBuffer;
int length;
string subBlock = @"\StringFileInfo\" + langCodePage +
@"\FileDescription";
result = VerQueryValue(buffer, subBlock, &lpBuffer, &length);
but then I don''t have a byte[] to pass to an ASCIEncoding object to
decode.
What I really want to do is declare
byte[]* lplpBuffer
and then pass that to VerQueryValue, but C# apparently won''t allow that.
(Oddly enough if I declare
byte[] lpBuffer;
I get an error "cannot convert from byte[]* to byte**", which is peculiar
if
it doesn''t recognise byte[]* as a type anyway)
Can anyone shed any light?
--
Dave



不需要使用指针,通过引用传递byte []:

byte [] lpBuffer;
VerQueryValue(....,ref lpBuffer ,...);

威利。



No need to use pointers, pass the byte[] by reference:

byte[] lpBuffer;
VerQueryValue(...., ref lpBuffer,...);

Willy.





" Dave" ; <沓** @ discussions.microsoft.com>在留言中写道

新闻:1F ********************************** @ microsof t.com ...

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
''没有!这使得无法从''转换字节[]''转换为''字节**''
-
''Fraid not! That gives "cannot convert from ''ref byte[]'' to ''byte**''
--




你如何拥有声明的功能?


David



How do you have the function declared?

David


这篇关于如何声明一个庞大的字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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