I am converting an application written in vb6 to vb.net. One of the things this application does is that it sends a Type object to the DLL. I tried converting the type to a structure and p / call the dll, but it does not seem to work. Ive stuck for a week any help would be greatly appreciated
here is vb6 code for type
'Define WICS Communications Control Block (CCB). Type WicsCCBType ' Create user-defined type. CCBNum As String * 1 CCBVer As String * 1 Resp1 As String * 4 Resp2 As String * 4 PLUA As String * 8 LLUA As String * 8 Mode As String * 8 ReqMax As String * 5 ResMax As String * 5 End Type
and this is what the dll is called
Private Declare Sub WICSRASP Lib "wicsrasp.dll" (MyWicsCCB As WicsCCBType) WICSRASP MyWicsCCB
this is what i tried with vb.net but it doesn't work
'Define WICS Communications Control Block (CCB). <System.Runtime.InteropServices.StructLayoutAttribute( _ System.Runtime.InteropServices.LayoutKind.Sequential, _ CharSet:=System.Runtime.InteropServices.CharSet.[Unicode])> _ Structure WicsCCBType ' Create user-defined type. <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=1)> Dim CCBNum As String <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=1)> Dim CCBVer As String <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=4)> Dim Resp1 As String <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=4)> Dim Resp2 As String <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=8)> Dim PLUA As String <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=8)> Dim LLUA As String <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=8)> Dim Mode As String <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=5)> Dim ReqMax As String <MarshalAs(UnmanagedType.ByValTStr, sizeconst:=5)> Dim ResMax As String End Structure
and this is where I tried to call him
<System.Runtime.InteropServices.DllImportAttribute("C:\windows\system32\wicsrasp.dll")> _ Public Shared Sub WICSRASP( ByRef CCB As WicsCCBType, ByRef Request As DAWicsRequestType, ByRef Response As DAWicsResponseType) End Sub Dim CCB As New modWICSDiary.WicsCCBType() CCB.CCBNum = "B" CCB.CCBVer = "2" CCB.LLUA = " " CCB.Mode = "CICSMO2 " CCB.ReqMax = "2100 " CCB.ResMax = "2100 " CCB.Resp1 = "0 " CCB.Resp2 = "0 " CCB.PLUA = "WICSPLU " NativeMethods.WICSRASP(CCB)
As for the values, the same values ββwork for the vb6 type
thanks again in advance