Click here to Skip to main content
15,885,546 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionWindows Installer Condition sytax Pin
Karma3125115-May-07 8:42
Karma3125115-May-07 8:42 
AnswerRe: Windows Installer Condition sytax Pin
Joseph Guadagno15-May-07 11:51
Joseph Guadagno15-May-07 11:51 
GeneralRe: Windows Installer Condition sytax Pin
Karma3125117-May-07 9:16
Karma3125117-May-07 9:16 
GeneralRe: Windows Installer Condition sytax Pin
Joseph Guadagno17-May-07 12:22
Joseph Guadagno17-May-07 12:22 
QuestionFavorite free toolbox controls? Pin
gdijim15-May-07 8:27
gdijim15-May-07 8:27 
QuestionRemoving an object from a list Pin
steve_rm15-May-07 8:06
steve_rm15-May-07 8:06 
AnswerRe: Removing an object from a list Pin
Dave Kreskowiak15-May-07 10:18
mveDave Kreskowiak15-May-07 10:18 
QuestionMarshalling Variable-Size Array Pin
VFaul15-May-07 7:49
VFaul15-May-07 7:49 
I'm calling an unmanaged native WLAN API method, WlanEnumInterfaces, that returns a pointer to a structure (WLAN_INTERFACE_INFO_LIST). There are three components to the structure. The third component is an array (WLAN_INTERFACE_INFO) of variable size. The first component in the structure is the number of items in the array.

I'm having trouble marshalling the data. I am using Marshal.PtrToStructure. I get the following exception:
"Cannot marshal field 'InterfaceList' of type "WLAN_INTERFACE_INFO_LIST": Invalid managed/unmanaged type combination (Arrays fields must be paired with ByValArray or SafeArray)."

Since the array size is variable, I marshal using UnmanagedType.LPArray and SizeParamIndex.

Below is my code. The call to WlanEnumInterfaces() is successful and I can view the contents of the structure in memory. The exception occurs at Marshal.PtrToStructure.

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Structure WLAN_INTERFACE_INFO
<MarshalAs(UnmanagedType.Struct)> Public InterfaceGuid As GUID
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public strInterfaceDescription() As String
<MarshalAs(UnmanagedType.I4)> Public isState As WLAN_INTERFACE_STATE
End Structure

<StructLayout(LayoutKind.Sequential)> _
Public Structure WLAN_INTERFACE_INFO_LIST
<MarshalAs(UnmanagedType.U4)> Public NumberOfItems As UInteger
<MarshalAs(UnmanagedType.U4)> Public Index As UInteger
<MarshalAs(UnmanagedType.LPArray, SizeParamIndex:=0)> Public InterfaceList() As WLAN_INTERFACE_INFO
End Structure

Dim pTemp As IntPtr
Dim WlanInterfaceList As WLAN_INTERFACE_INFO_LIST
ui32Status = WlanEnumInterfaces(WlanHandle,IntPtr.Zero, pTemp)
WlanInterfaceList = Marshal.PtrToStructure(pTemp, GetType(WLAN_INTERFACE_INFO_LIST))

Any help is appreciated.
VF
AnswerRe: Marshalling Variable-Size Array Pin
Dave Kreskowiak15-May-07 10:12
mveDave Kreskowiak15-May-07 10:12 
QuestionNotifyIcon and ContextMenuStrip Pin
viperbyte65015-May-07 5:54
viperbyte65015-May-07 5:54 
AnswerRe: NotifyIcon and ContextMenuStrip Pin
Dave Kreskowiak15-May-07 9:54
mveDave Kreskowiak15-May-07 9:54 
GeneralRe: NotifyIcon and ContextMenuStrip Pin
viperbyte65015-May-07 10:39
viperbyte65015-May-07 10:39 
GeneralRe: NotifyIcon and ContextMenuStrip Pin
Dave Kreskowiak15-May-07 12:51
mveDave Kreskowiak15-May-07 12:51 
QuestionDetermine Path of Windows Folder Pin
Rupesh Kumar Swami15-May-07 4:14
Rupesh Kumar Swami15-May-07 4:14 
AnswerRe: Determine Path of Windows Folder Pin
Dave Kreskowiak15-May-07 4:37
mveDave Kreskowiak15-May-07 4:37 
QuestionRe: Determine Path of Windows Folder Pin
Rupesh Kumar Swami15-May-07 6:08
Rupesh Kumar Swami15-May-07 6:08 
AnswerRe: Determine Path of Windows Folder Pin
Dave Kreskowiak15-May-07 6:12
mveDave Kreskowiak15-May-07 6:12 
AnswerRe: Determine Path of Windows Folder Pin
The ANZAC15-May-07 13:14
The ANZAC15-May-07 13:14 
QuestionAccess verses SQL Server [modified] Pin
Werries15-May-07 3:56
Werries15-May-07 3:56 
AnswerRe: Access verses SQL Server Pin
Dave Kreskowiak15-May-07 4:25
mveDave Kreskowiak15-May-07 4:25 
AnswerRe: Access verses SQL Server Pin
Polymorpher15-May-07 17:53
Polymorpher15-May-07 17:53 
QuestionSelect all of the text in a textbox Pin
Marcus J. Smith15-May-07 3:36
professionalMarcus J. Smith15-May-07 3:36 
AnswerRe: Select all of the text in a textbox Pin
Dave Kreskowiak15-May-07 4:17
mveDave Kreskowiak15-May-07 4:17 
GeneralRe: Select all of the text in a textbox Pin
Marcus J. Smith15-May-07 5:45
professionalMarcus J. Smith15-May-07 5:45 
AnswerRe: Select all of the text in a textbox Pin
TwoFaced15-May-07 4:22
TwoFaced15-May-07 4:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.