By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,163 Members | 1,284 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,163 IT Pros & Developers. It's quick & easy.

Translate from C++

P: n/a
Hi all,
I need some help translating a C++ function that returns a pointer to a
Structure.

Here is the original C++ declare:
LPBITMAPINFO IMAPI ImgGetInfo(HANDLE hImage, LPINT lpbFlags)

Here's what I have so far in the VB.NET version:
<Serializable(), StructLayout(LayoutKind.Sequential)> _
Public Structure BITMAPINFOHEADER '40 bytes
Public biSize As Integer
Public biWidth As Integer
Public biHeight As Integer
Public biPlanes As Short
Public biBitCount As Integer
Public biCompression As Integer
Public biSizeImage As Integer
Public biXPelsPerMeter As Integer
Public biYPelsPerMeter As Integer
Public biClrUsed As Short
Public biClrImportant As Integer
End Structure

<Serializable(), StructLayout(LayoutKind.Sequential)> _
Public Structure BITMAPINFO
Public bmiHeader As BITMAPINFOHEADER
Public bmiColors As RGBQUAD
End Structure

<Serializable(), StructLayout(LayoutKind.Sequential)> _
Public Structure RGBQUAD
Public rgbBlue As Byte
Public rgbGreen As Byte
Public rgbRed As Byte
Public rgbReserved As Byte
End Structure

Declare Ansi Function ImgGetInfo Lib "someDLLname.dll" (ByVal img As
Integer, ByRef lFlags As Integer) As BITMAPINFO

Can someone tell me if the VB.net translation is correct, and if not, how to
do the VB.Net declare correctly?

Thanks!
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Try this:

Declare Ansi Function ImgGetInfo Lib "someDLLname.dll" (ByVal img As _
Integer, ByRef lFlags As Integer) As IntPtr

Dim StructPtr As IntPtr = ImgGetInfo(img, lFlags)

Dim MyStruct As BITMAPINFO = CType(Marshal.PtrToStructure(StructPtr, _
GetType(BITMAPINFO)), BITMAPINFO)

hope that helps..
Imran.

"Rush" <Ru**@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
Hi all,
I need some help translating a C++ function that returns a pointer to a
Structure.

Here is the original C++ declare:
LPBITMAPINFO IMAPI ImgGetInfo(HANDLE hImage, LPINT lpbFlags)

Here's what I have so far in the VB.NET version:
<Serializable(), StructLayout(LayoutKind.Sequential)> _
Public Structure BITMAPINFOHEADER '40 bytes
Public biSize As Integer
Public biWidth As Integer
Public biHeight As Integer
Public biPlanes As Short
Public biBitCount As Integer
Public biCompression As Integer
Public biSizeImage As Integer
Public biXPelsPerMeter As Integer
Public biYPelsPerMeter As Integer
Public biClrUsed As Short
Public biClrImportant As Integer
End Structure

<Serializable(), StructLayout(LayoutKind.Sequential)> _
Public Structure BITMAPINFO
Public bmiHeader As BITMAPINFOHEADER
Public bmiColors As RGBQUAD
End Structure

<Serializable(), StructLayout(LayoutKind.Sequential)> _
Public Structure RGBQUAD
Public rgbBlue As Byte
Public rgbGreen As Byte
Public rgbRed As Byte
Public rgbReserved As Byte
End Structure

Declare Ansi Function ImgGetInfo Lib "someDLLname.dll" (ByVal img As
Integer, ByRef lFlags As Integer) As BITMAPINFO

Can someone tell me if the VB.net translation is correct, and if not, how
to
do the VB.Net declare correctly?

Thanks!

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.