473,466 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Converting C# to VB.net question. what is [StructLayout(LayoutKind.Sequential)]?

H
I am try to convert C# to vb.net I don’t know what would be an equivalent statements in VB.net any help will be appreciated.

[StructLayout(LayoutKind.Sequential)
public class BITMAPINFOHEADER
public int biSize = Marshal.SizeOf(typeof(BITMAPINFOHEADER)
public int biWidt
public int biHeigh
public short biPlane
public short biBitCoun
public int biCompressio
public int biSizeImag
public int biXPelsPerMete
public int biYPelsPerMete
public int biClrUse
public int biClrImportan
' <summary
' Holds all bitmap informatio
' </summary
[StructLayout(LayoutKind.Sequential)
public class BITMAPINFO
public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER(

[MarshalAs(System.Runtime.InteropServices.Unmanaged Type.ByValArray, SizeConst=BITMAPINFO_MAX_COLORSIZE*4)
public byte[] bmiColors ' RGBQUAD structs... Blue-Green-Red-Reserved, repeat..
' <summary
' Palette entry structur
' </summary
[StructLayout(LayoutKind.Sequential)
public struct PALETTEENTRY
public byte peRe
public byte peGree
public byte peBlu
public byte peFlag
' <summary
' Holds all bitmap information in a flat structure (contains no other classes or structs
' </summary
[StructLayout(LayoutKind.Sequential)
public struct BITMAPINFO_FLAT
public int bmiHeader_biSize' = Marshal.SizeOf(typeof(BITMAPINFOHEADER)
public int bmiHeader_biWidt
public int bmiHeader_biHeigh
public short bmiHeader_biPlane
public short bmiHeader_biBitCoun
public int bmiHeader_biCompressio
public int bmiHeader_biSizeImag
public int bmiHeader_biXPelsPerMete
public int bmiHeader_biYPelsPerMete
public int bmiHeader_biClrUse
public int bmiHeader_biClrImportan

[MarshalAs(System.Runtime.InteropServices.Unmanaged Type.ByValArray, SizeConst=BITMAPINFO_MAX_COLORSIZE*4)
public byte[] bmiColors ' RGBQUAD structs... Blue-Green-Red-Reserved, repeat..
' Native method
[DllImport("gdi32")
public static extern int GetPaletteEntries(int hpal, int iStartIndex, int nEntries, byte[] lppe
[DllImport("gdi32")
public static extern int GetSystemPaletteEntries(int hdc, int iStartIndex, int nEntries, byte[] lppe
[DllImport("gdi32")
public static extern int CreateDIBSection(int hdc, ref NativeMethods.BITMAPINFO_FLAT bmi, int iUsage, ref int ppvBits, int hSection, int dwOffset
[DllImport("gdi32")
public static extern int GetObjectType(int hobject
[DllImport("gdi32")
public static extern int CreateCompatibleDC(int hDC
[DllImport("gdi32")
public static extern int CreateCompatibleBitmap(int hDC, int width, int height
[DllImport("gdi32")
public static extern int GetDIBits(int hdc, int hbm, int arg1, int arg2, int arg3, NativeMethods.BITMAPINFOHEADER bmi, int arg5
[DllImport("gdi32")
public static extern int GetDIBits(int hdc, int hbm, int arg1, int arg2, int arg3, ref NativeMethods.BITMAPINFO_FLAT bmi, int arg5
[DllImport("gdi32")
public static extern int SelectObject(int hdc, int obj
[DllImport("gdi32")
public static extern bool DeleteObject(int hObject
[DllImport("gdi32")]
public static extern bool DeleteDC(int hDC)
[DllImport("gdi32")]
public static extern bool BitBlt(int hDC, int x, int y, int nWidth, int nHeight,
int hSrcDC, int xSrc, int ySrc, int dwRop)
[DllImport("gdi32")]
public static extern int GetDeviceCaps(int hDC, int nIndex)
}

Nov 16 '05 #1
2 12302
Are you simply asking about the declaration? The attribute would be declared the same way in VB.NET as in C#, except with pointy brackets instead of square brackets

<StructLayout(LayoutKind.Sequential)

By specifiying the struct layout, you are telling the CLR specifically how to arrange the fields of your struct in memory. Normally, this is handled by the CLR and you could care less about its in-memory layout, but when dealing with unmanaged code, there are many cases where the code being called expects a certain layout, so the StructLayout attribute allows you to specify it explicitly.
Nov 16 '05 #2
Why are you going from C# to VB?

VB shouldnt even be called a programming language.

Regards
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Carlos Guzmán Álvarez | last post by:
Hello: I'm trying to execute a function of a unmanaged dll using PInvoke, i have definied the function as: public static extern int isc_dsql_prepare( int status_vector, ref int...
7
by: Kevin | last post by:
Hi al I have an interesting question.... I am working witha Win API this is the Function Public Declare Function EnumJobs Lib "winspool.drv" Alias "EnumJobsA" (ByVal hPrinter As Long, ByVal...
2
by: chaor | last post by:
hi, how to convert the following strut into safe struct in c#? struct in C++: typedef struct { char m_username; char m_password; char m_userIP;
3
by: VMI | last post by:
How can I convert the following C struct into a C# struct? The struct is sent to an API function (written in C) as parameter, and the function fills it with data. I tried to convert it and most of...
1
by: VMI | last post by:
How can I convert this struct into a C# struct? The problem with this one is that one of its members is an array of ADDR_REC(another struct), and the API function (written in C) writes to this part...
3
by: Thomas Connolly | last post by:
Hello list, No one seems to be replying to my request on the interop group so I thought I would try here. Can someone please help me with this? I have a C struct containing function pointers like...
0
by: Al Bahr | last post by:
H I am try to convert C# to vb.net I don’t know what would be an equivalent statements in VB.net any help will be appreciated bmiColors ' RGBQUAD structs... Blue-Green-Red-Reserved, repeat.. ...
7
by: GS | last post by:
in VS .net vb 2005 express, I failed to find the option for leaving out warning in the Errors tab but still leave Warning in the warning tab listing. Can someone give me some hints? thank you...
6
by: canoewhiteh2o | last post by:
I am converting a couple of C header files to C#. It is mainly just a bunch C structs but I am not sure how to handle the #ifdef and #ifndef in C#. For example: #ifndef DATE_TIME #define...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.