How to get back byte[] when calling Win32 api function ?

  • Thread starter Thread starter Pawel
  • Start date Start date
P

Pawel

Hi,

I will get back (receive) byte array from function desribed below:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( out byte[] bufer );

Here below sample code:

byte[] array_byte=null;

CLMQGet( out array_byte ); // here is exeption calling

Say me why this execption is calling and how can i change my solution ?

Thanks for any help,

Regards,
Pawel
 
you need to check out the following link:

http://msdn.microsoft.com/library/d...uide/html/cpconDefaultMarshalingForArrays.asp

you cannot use out (or ref) with byte[] parameters because this will cause
the address of the internal object (not the buffer) to be passed to the
unmanaged code.

You should be able to just define the signature as and then change the code
accordingly:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( byte[] bufer );


HTH

Ollie Riches
 
Hi,

Thanks for you response.

Can you help me how can i declare parameter in my function, that can i
receive gzip compressed buffer.

For example:
Declaration here:
[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet(here someone type but i dont know how
receive compressed gzip buffer);


My Program below:
// Here call this function
CLMQGet(here receive this compressed gzip file);

Now i will make following tasks:
1. Create file and write this buffer to file with gzip extension
2. Uncompress this gzip file.

Can you prompt me which type should i select to receive this compressed gzip
buffer
Thanks for any suggestions

Regards,
Pawel



U¿ytkownik "Ollie Riches said:
you need to check out the following link:

http://msdn.microsoft.com/library/d...uide/html/cpconDefaultMarshalingForArrays.asp

you cannot use out (or ref) with byte[] parameters because this will cause
the address of the internal object (not the buffer) to be passed to the
unmanaged code.

You should be able to just define the signature as and then change the
code accordingly:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( byte[] bufer );


HTH

Ollie Riches

Pawel said:
Hi,

I will get back (receive) byte array from function desribed below:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( out byte[] bufer );

Here below sample code:

byte[] array_byte=null;

CLMQGet( out array_byte ); // here is exeption calling

Say me why this execption is calling and how can i change my solution ?

Thanks for any help,

Regards,
Pawel
 
where is CLMQGet defined, is it an MS defined win32 API or a third party?

Ollie Riches



Pawel said:
Hi,

Thanks for you response.

Can you help me how can i declare parameter in my function, that can i
receive gzip compressed buffer.

For example:
Declaration here:
[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet(here someone type but i dont know how
receive compressed gzip buffer);


My Program below:
// Here call this function
CLMQGet(here receive this compressed gzip file);

Now i will make following tasks:
1. Create file and write this buffer to file with gzip extension
2. Uncompress this gzip file.

Can you prompt me which type should i select to receive this compressed
gzip buffer
Thanks for any suggestions

Regards,
Pawel



U¿ytkownik "Ollie Riches said:
you need to check out the following link:

http://msdn.microsoft.com/library/d...uide/html/cpconDefaultMarshalingForArrays.asp

you cannot use out (or ref) with byte[] parameters because this will
cause the address of the internal object (not the buffer) to be passed to
the unmanaged code.

You should be able to just define the signature as and then change the
code accordingly:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( byte[] bufer );


HTH

Ollie Riches

Pawel said:
Hi,

I will get back (receive) byte array from function desribed below:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( out byte[] bufer );

Here below sample code:

byte[] array_byte=null;

CLMQGet( out array_byte ); // here is exeption calling

Say me why this execption is calling and how can i change my solution ?

Thanks for any help,

Regards,
Pawel
 
Third party function in C declared in following way :
LONG CLMQGet( LPVOID lpsBuff );

How can i receive this in C# using dotNET datatype ?

Regards,

Pawel

U¿ytkownik "Ollie Riches said:
where is CLMQGet defined, is it an MS defined win32 API or a third party?

Ollie Riches



Pawel said:
Hi,

Thanks for you response.

Can you help me how can i declare parameter in my function, that can i
receive gzip compressed buffer.

For example:
Declaration here:
[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet(here someone type but i dont know how
receive compressed gzip buffer);


My Program below:
// Here call this function
CLMQGet(here receive this compressed gzip file);

Now i will make following tasks:
1. Create file and write this buffer to file with gzip extension
2. Uncompress this gzip file.

Can you prompt me which type should i select to receive this compressed
gzip buffer
Thanks for any suggestions

Regards,
Pawel



U¿ytkownik "Ollie Riches said:
you need to check out the following link:

http://msdn.microsoft.com/library/d...uide/html/cpconDefaultMarshalingForArrays.asp

you cannot use out (or ref) with byte[] parameters because this will
cause the address of the internal object (not the buffer) to be passed
to the unmanaged code.

You should be able to just define the signature as and then change the
code accordingly:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( byte[] bufer );


HTH

Ollie Riches

Hi,

I will get back (receive) byte array from function desribed below:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( out byte[] bufer );

Here below sample code:

byte[] array_byte=null;

CLMQGet( out array_byte ); // here is exeption calling

Say me why this execption is calling and how can i change my solution ?

Thanks for any help,

Regards,
Pawel
 
What is the LPVOID representing?

check out the following:

http://groups.google.com/groups?q=LPVOID+C#&hl=en&lr=&sa=N&tab=wg

HTH

Ollie Riches


Pawel said:
Third party function in C declared in following way :
LONG CLMQGet( LPVOID lpsBuff );

How can i receive this in C# using dotNET datatype ?

Regards,

Pawel

U¿ytkownik "Ollie Riches said:
where is CLMQGet defined, is it an MS defined win32 API or a third party?

Ollie Riches



Pawel said:
Hi,

Thanks for you response.

Can you help me how can i declare parameter in my function, that can i
receive gzip compressed buffer.

For example:
Declaration here:
[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet(here someone type but i dont know how
receive compressed gzip buffer);


My Program below:
// Here call this function
CLMQGet(here receive this compressed gzip file);

Now i will make following tasks:
1. Create file and write this buffer to file with gzip extension
2. Uncompress this gzip file.

Can you prompt me which type should i select to receive this compressed
gzip buffer
Thanks for any suggestions

Regards,
Pawel



U¿ytkownik "Ollie Riches" <[email protected]> napisa³ w
wiadomo¶ci you need to check out the following link:

http://msdn.microsoft.com/library/d...uide/html/cpconDefaultMarshalingForArrays.asp

you cannot use out (or ref) with byte[] parameters because this will
cause the address of the internal object (not the buffer) to be passed
to the unmanaged code.

You should be able to just define the signature as and then change the
code accordingly:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( byte[] bufer );


HTH

Ollie Riches

Hi,

I will get back (receive) byte array from function desribed below:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( out byte[] bufer );

Here below sample code:

byte[] array_byte=null;

CLMQGet( out array_byte ); // here is exeption calling

Say me why this execption is calling and how can i change my solution
?

Thanks for any help,

Regards,
Pawel
 
Hi,
LPVOID lpsBuff - this is a pointer for someone buffer in memory that is
compressed with gzip (befor was writing to this buffer )

Pawel

U¿ytkownik "Ollie Riches said:
What is the LPVOID representing?

check out the following:

http://groups.google.com/groups?q=LPVOID+C#&hl=en&lr=&sa=N&tab=wg

HTH

Ollie Riches


Pawel said:
Third party function in C declared in following way :
LONG CLMQGet( LPVOID lpsBuff );

How can i receive this in C# using dotNET datatype ?

Regards,

Pawel

U¿ytkownik "Ollie Riches said:
where is CLMQGet defined, is it an MS defined win32 API or a third
party?

Ollie Riches



Hi,

Thanks for you response.

Can you help me how can i declare parameter in my function, that can i
receive gzip compressed buffer.

For example:
Declaration here:
[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet(here someone type but i dont know how
receive compressed gzip buffer);


My Program below:
// Here call this function
CLMQGet(here receive this compressed gzip file);

Now i will make following tasks:
1. Create file and write this buffer to file with gzip extension
2. Uncompress this gzip file.

Can you prompt me which type should i select to receive this compressed
gzip buffer
Thanks for any suggestions

Regards,
Pawel



U¿ytkownik "Ollie Riches" <[email protected]> napisa³ w
wiadomo¶ci you need to check out the following link:

http://msdn.microsoft.com/library/d...uide/html/cpconDefaultMarshalingForArrays.asp

you cannot use out (or ref) with byte[] parameters because this will
cause the address of the internal object (not the buffer) to be passed
to the unmanaged code.

You should be able to just define the signature as and then change the
code accordingly:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( byte[] bufer );


HTH

Ollie Riches

Hi,

I will get back (receive) byte array from function desribed below:

[DllImport("clamqa.dll", CharSet=CharSet.Ansi, EntryPoint="CLMQGet")]
public static extern int CLMQGet( out byte[] bufer );

Here below sample code:

byte[] array_byte=null;

CLMQGet( out array_byte ); // here is exeption calling

Say me why this execption is calling and how can i change my solution
?

Thanks for any help,

Regards,
Pawel
 
Back
Top