Click here to Skip to main content
16,021,823 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: File in use error while renaming file Pin
Christian Graus15-May-07 12:15
protectorChristian Graus15-May-07 12:15 
GeneralRe: File in use error while renaming file Pin
Steve Erbach16-May-07 3:34
Steve Erbach16-May-07 3:34 
Questionhow to convert the following code to vb.net Pin
awara15-May-07 11:44
awara15-May-07 11:44 
AnswerRe: how to convert the following code to vb.net Pin
MatrixCoder15-May-07 12:07
MatrixCoder15-May-07 12:07 
AnswerRe: how to convert the following code to vb.net Pin
Dave Doknjas15-May-07 12:18
Dave Doknjas15-May-07 12:18 
Questionhow to convert the following code to vb.net Pin
awara15-May-07 11:44
awara15-May-07 11:44 
AnswerRe: how to convert the following code to vb.net Pin
nlarson1116-May-07 11:15
nlarson1116-May-07 11:15 
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 

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.