Passaggio dei dati a Win32 API

pubblicato il 12/07/2007 aggiornato il 24/08/2009

A volte capita di dover richiamare anche dal codice VB.NET delle funzioni contenute nelle API di sistema; il grosso problema spesso č quello della conversione tra il tipo di dato definito nelle API e il relatuvo tipo di dato definito nel mondo VB.NET.

Parametro Win32 Tipo VB.NET
BYTE ByVal As Byte
CHAR ByVal As Char
DWORD ByVal As Integer
HWND ByVal As IntPtr
INT ByVal As Integer
LONG ByVal As Integer
LPBYTE ByRef As Byte
LPCHAR ByRef As Char
LPDWORD ByRef As Integer
LPLONG ByRef As Integer
LPSHORT ByRef As Short
LPSTR ByVal As String
LPWORD ByRef As Short
SHORT ByVal As Short
ULONG ByVal As Integer
USHORT ByVal As Short
WORD ByVal As Short

A quick reference : PInvoke.NET