Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8095183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:02:16+00:00 2026-06-05T21:02:16+00:00

I am converting an application originally written in vb6 to vb.net. One of the

  • 0

I am converting an application originally written in vb6 to vb.net. One of the things this application does is that it sends a “Type” object to a dll. I tried converting the type to a structure and p/invoking the dll but it does not seem to work. I’ve been stuck for a week any help would be really appreciated

here is the vb6 code for the 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 here is how 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 is not working

'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 here is where i tried to call it

<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 to the values, the same values work for the vb6 type

again thank you in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:02:18+00:00Added an answer on June 5, 2026 at 9:02 pm

    I don’t know if this has been solved by the OP yet, but here’s my take on it.

    Fixed-length strings inside UDTs in VB6 are not marshalled as pointers but are inlined into the structure. Additionally, VB6 converts Unicode to Ansi before marshalling. And VB6 uses 4 byte alignment.

    The type will look this this in memory with the padding, with each successive field being named A through I in the illustration, and _ being a pad byte due to alignment.

    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 
    ||  |   |   |       |       |       |       |
    ||  |   |   |       |       |       |       |
    VV  V   V   V       V       V       V       V
    
    AB__CCCCDDDDEEEEEEEEFFFFFFFFGGGGGGGGHHHHH___IIIII___
    

    Therefore the CharSet should be Ansi, the StructAlignment should be 4. The use of ByValTString is fine, as is the use of SizeConst.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm converting a VB6 application to VB.Net that draws on picture boxes. Naturally I
I'm converting an application from VB6 to VB.NET, and am required to declare and
I'm converting my Android application to use fragments. Previously, I had an activity that
in the application simplexml has been converting an rss feed to an object and
Currently, I'm sitting on an ugly business application written in Access that takes a
I have an application that originally needed to connect to Sybase (via ODBC), but
I have a Windows Application written in C# VS 2008. The purpose of this
I'm converting an application I've written and part of it is a GoogleMap component
Some weird stuff is happening, I am converting an application that used to use
We are converting a VB6 application to C# (4.0). and have come across a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.