VB.NET features
----- structlayout features
The StructLayout feature allows us to control the elements of the Structure state block in memory, and when these elements are passed to the external DLL, the runtime is arranged. The sequence of members of the Visual Basic structure is arranged in the order in which they appear in the source code, although the compiler can arrange these members to arrange these members in order to make 16-bit numerical sub-boundary alignment, 32-bit The value is aligned with a double word boundary.
Use this arrangement (unparalleled layout) optimal performance.
The user-defined structure in Visual Basic 6 is uncompressed, and we cannot change this default setting. This setting can be changed in VB.NET and can accurately control the location of each structural member via System.Runtime.InteropServices.StructLayout features. System.Runtime.InteropServices.StructLayout allowed with StructLayout.auto structlayout.sequential structlayout.explicit.
Imports system.Runtime.InteropServices
Structure test
...
End structure
StructLayout features support three additional fields: Charset, Pack, Size.
• Charset defines the arrangement of string members in the structure to pass to the DLL. Can be Unicode, ANSI, or Auto.
The default is AUTO, and the string represents the string in WIN NT / 2000 / XP to arrange according to the Unicode string, and in WIN 95/98 / ME, it is indicated in accordance with the ANSI string.
· Pack defines the package size of the structure. It can be 1, 2, 4, 8, 16, 32, 64, 128, or special value 0. Special value 0 represents the default compression size of the current operation platform.
Imports system.Runtime.InteropServices
Structure test
...
End structure