Uint data type in VB.NET when calling a DLL

G

Guest

I have converted the code shown below from C#. My problem involves the uint
data type. When converted to VB.NET it becomes: Uint32 and causes two
compile errors. The error message in VB.NET involves not being able to
convert between Uint32 and Integer. The error messages occur in the two Dim
statements in the VB.NET GetRtfImage() method.

I can make the code compile by changing Uint32 to Int32 but will this
conversion make the dll not respond properly? Is there another solution? I
am not sure how important an unsigned integer is to the referenced dll.

partial C# code:
[DllImportAttribute("gdiplus.dll")]
private static extern uint GdipEmfToWmfBits (IntPtr _hEmf, uint _bufferSize,
byte[] _buffer, int _mappingMode, EmfToWmfBitsFlags _flags);

When converted to VB.NET and stripped of non essential code, I end up with:

Private Shared Function GdipEmfToWmfBits(ByVal bufferSize As System.UInt32)
As System.UInt32
End Function

Private Sub GetRtfImage(ByVal image As Image)
Dim bufferSize As System.UInt32 = GdipEmfToWmfBits(0)
Dim buffer(bufferSize) As Byte
End Sub
 
H

Herfried K. Wagner [MVP]

genojoe said:
I can make the code compile by changing Uint32 to Int32 but will this
conversion make the dll not respond properly? Is there another solution?
I
am not sure how important an unsigned integer is to the referenced dll.

partial C# code:
[DllImportAttribute("gdiplus.dll")]
private static extern uint GdipEmfToWmfBits (IntPtr _hEmf, uint
_bufferSize,
byte[] _buffer, int _mappingMode, EmfToWmfBitsFlags _flags);

When converted to VB.NET and stripped of non essential code, I end up
with:

Private Shared Function GdipEmfToWmfBits(

Your declare is wrong. Take a look at the code in the following post:

Private Sub GetRtfImage(ByVal image As Image)
Dim bufferSize As System.UInt32 = GdipEmfToWmfBits(0)

Dim buffer(bufferSize) As Byte

'Dim buffer(Convert.ToInt32(bufferSize)) As Byte'.
 

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