I am trying to work with the RasDialA function that takes a structure which
contains several string, but cannot get it to work.
In VB6 the structure called RASDIALPARAMS is as so...
'Type declaration for RASDIALPARAM structure
Public Type RasDialParams
dwSize As Long
szEntryName(MaxEntryName) As Byte
szPhoneNumber(RAS_MaxPhoneNumber) As Byte
szCallbackNumber(MaxCallbackNumber) As Byte
szUserName(UNLEN) As Byte
szPassword(PWLEN) As Byte
szDomain(DNLEN) As Byte
End Type
My .NET Version Is as so...
Public Structure RASDIALPARAMS
Public iSize As Int32
Public sEntryName() As Byte
Public sPhoneNumber() As Byte
Public sCallbackNumber() As Byte
Public sUserName() As Byte
Public sPassword() As Byte
Public sDomain() As Byte
Public iSubEntry As Int32
Public iCallbackVal As Int32
End Structure
Since I cannot create arrays with dimension I do that when the structure is
created locally with a procedure.
The size of the 2 structures are not equivelent the vb6 structure is 1052
bytes, while the .NET structure is 36. Which means to me that the array
definitions are merely place holders for the array. How can I get my
structures to work properly?
Mattias Sjögren - 21 Sep 2005 20:47 GMT
>The size of the 2 structures are not equivelent the vb6 structure is 1052
>bytes, while the .NET structure is 36. Which means to me that the array
>definitions are merely place holders for the array. How can I get my
>structures to work properly?
Add the attribute
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=123)>
before each array member (and replace 123 with the actual array size).
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.