DLL's

G

Guest

I am trying to call an unmanaged function from vb.net. I have declared the DLL as follows:

Private Declare Function uncompress Lib "zlib.dll" (ByRef dest As Byte(), ByVal destLen As Long, ByRef src As Byte(), ByVal srcLen As Long) As Long

When I try to call the function, I get an error "Object Referennce not set to instance of object". I have dimensioned all the byte arrays and the other two variables to long.

I think it's in the way the variables are handled in unmanaged code versus vb.net but not sure exactly what to do. Any help would be very much appreciated.

Dennis in Houston
 
C

Cor Ligthert

Hi Dennis,

Without to look at your questior further, did you know that a classic VB
Long is now an Integer?

I think that you have first to past that part.

Cor
 
H

Herfried K. Wagner [MVP]

* =?Utf-8?B?RGVubmlz?= said:
I am trying to call an unmanaged function from vb.net. I have declared the DLL as follows:

Private Declare Function uncompress Lib "zlib.dll" (ByRef dest As Byte(), ByVal destLen As Long, ByRef src As Byte(), ByVal srcLen As Long) As Long

Your declare is wrong:

<URL:http://groups.google.de/groups?selm=u3sUJ8QVCHA.2336@tkmsftngp09>

BTW: If you are looking for a managed ZIP solution:

<URL:http://www.icsharpcode.net/OpenSource/SharpZipLib/>

The VB.NET Resource Kit contains zipping functionality too:

<URL:http://msdn.microsoft.com/vbasic/vbrkit/>

It contains ComponentOne Zip for .NET:

<URL:http://www.componentone.com/products.aspx?ProductCode=1&ProductID=26>

Using J#'s zip functionality:

<URL:http://msdn.microsoft.com/msdnmag/issues/03/06/zipcompression/print.asp>
 
G

Guest

Thanks for answer. I now understand that a long in previous VB versions is now an integer in VB.Net and already did know that strings were ANSI vs Unicode also. I'm still a bit confused as to how to pass arrays from vb.net to standard DLL's and how to declare them in both the declare statement for the standard dll function and how to delcare them in the calling function.
 
H

Herfried K. Wagner [MVP]

* =?Utf-8?B?RGVubmlz?= said:
Thanks for answer. I now understand that a long in previous VB
versions is now an integer in VB.Net

ACK. 'Long' is now a 64-bit datatype.
I'm still a bit confused as to how to pass arrays from vb.net to
standard DLL's and how to declare them in both the declare statement for
the standard dll function and how to delcare them in the calling
function.

That is very similar to how it was done in VB6, but the answer depends
on what the function is expecting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top