using c++ 6.0 DLL in VB.Net program, passing user defined Type

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • nickolais909@yahoo.com

    #1

    using c++ 6.0 DLL in VB.Net program, passing user defined Type

    Hello,
    I have an old C++ DLL that I am wishing to use in a VB.NET program.
    Previously I had a VB6 program that would pass a Type to a DLL
    function. For example, I would pass a variable of this Type in:

    Public Type ListInfo ' structure to hold information about the list
    file
    FileIndex As Integer
    filename(MAXNAM E) As Byte
    FileNum As Integer
    FileIcon As Integer
    End Type

    I am writing a new VB.NET program that will use the same DLL that was
    used by the VB6 program, but I have had to update the data type to be a
    structure:

    Public Structure ListInfo ' structure to hold information about
    the list file
    Dim FileIndex As Short
    Dim filename() As Byte
    Dim FileNum As Short
    Dim FileIcon As Short
    End Structure
    'integers made Shorts b/c of Int size change

    My DLL does not like the new data type. Does anyone know of a solution?

  • Herfried K. Wagner [MVP]

    #2
    Re: using c++ 6.0 DLL in VB.Net program, passing user defined Type

    <nickolais909@y ahoo.comschrieb :
    I have an old C++ DLL that I am wishing to use in a VB.NET program.
    Previously I had a VB6 program that would pass a Type to a DLL
    function. For example, I would pass a variable of this Type in:
    >
    Public Type ListInfo ' structure to hold information about the list
    file
    FileIndex As Integer
    filename(MAXNAM E) As Byte
    FileNum As Integer
    FileIcon As Integer
    End Type
    >
    I am writing a new VB.NET program that will use the same DLL that was
    used by the VB6 program, but I have had to update the data type to be a
    structure:
    >
    Public Structure ListInfo ' structure to hold information about
    the list file
    Dim FileIndex As Short
    Dim filename() As Byte
    Dim FileNum As Short
    Dim FileIcon As Short
    End Structure
    'integers made Shorts b/c of Int size change
    >
    My DLL does not like the new data type. Does anyone know of a solution?
    \\\
    Imports System.Runtime. InteropServices

    Public Structure ListInfo
    Public FileIndex As Short
    <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=MAXN AME)_
    Public filename() As Byte
    Public FileNum As Short
    Public FileIcon As Short
    End Structure
    ///

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    Working...