Upgrading VB6 API to VB.NET API calls

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shayne H

    Upgrading VB6 API to VB.NET API calls

    I have a VB6 UDT used in an API call as follows:

    Type RASCONN
    hRasConn As Long
    sEntryName As String
    sDeviceType As String
    sDeviceName As String
    sPhonebook As String
    lngSubEntry As Long
    guidEntry(15) As Byte
    End Type

    So converting to VB.NET structure:

    Structure RASCONN
    Public hRasConn As Integer
    Public sEntryName As String
    Public sDeviceType As String
    Public sDeviceName As String
    Public sPhonebook As String
    Public lngSubEntry As Integer
    Public guidEntry(15) As Byte **
    End Stucture

    ** The last field, guidEntry(15) cannot be used in a VB.NET structure
    because structure members cannot be declared with an intitial size.
    What is the best way to work around this in VB.NET?
    Any links to guidelines on making API calls from VB.NET would be greatly
    appreciated.
    I have looked for references on the web, but all of them were at a basic
    level.

    --
    Thanks for any help,
    Shayne H


  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: Upgrading VB6 API to VB.NET API calls

    Shayne,[color=blue]
    > guidEntry(15) As Byte[/color]
    Is guidEntry as GUID?

    If it is, I would use System.Guid instead of an array of bytes.
    [color=blue]
    > What is the best way to work around this in VB.NET?[/color]
    Alternatively there is a way to use MarshalAs attribute to indicate that
    guidEntry is to be marshaled as a 16 byte array. See
    System.Runtime. InteropServices .MarshalAsAttri bute, I don't have a sample
    immediately available.
    [color=blue]
    > Any links to guidelines on making API calls from VB.NET would be greatly
    > appreciated.[/color]

    I've been using Adam Nathan's book ".NET and COM - The Complete
    Interoperabilit y Guide" from SAMS press. Very complete (too complete?) :-)

    Also you can ask 'down the hall' in the
    microsoft.publi c.dotnet.framew ork.interop newsgroups for help on API calls.

    Hope this helps
    Jay

    "Shayne H" <shaynehATlycos SPAMGOTOHELLcoD OTuk> wrote in message
    news:upMGpqQhDH A.1688@TK2MSFTN GP10.phx.gbl...[color=blue]
    > I have a VB6 UDT used in an API call as follows:
    >
    > Type RASCONN
    > hRasConn As Long
    > sEntryName As String
    > sDeviceType As String
    > sDeviceName As String
    > sPhonebook As String
    > lngSubEntry As Long
    > guidEntry(15) As Byte
    > End Type
    >
    > So converting to VB.NET structure:
    >
    > Structure RASCONN
    > Public hRasConn As Integer
    > Public sEntryName As String
    > Public sDeviceType As String
    > Public sDeviceName As String
    > Public sPhonebook As String
    > Public lngSubEntry As Integer
    > Public guidEntry(15) As Byte **
    > End Stucture
    >
    > ** The last field, guidEntry(15) cannot be used in a VB.NET structure
    > because structure members cannot be declared with an intitial size.
    > What is the best way to work around this in VB.NET?
    > Any links to guidelines on making API calls from VB.NET would be greatly
    > appreciated.
    > I have looked for references on the web, but all of them were at a basic
    > level.
    >
    > --
    > Thanks for any help,
    > Shayne H
    >
    >[/color]


    Comment

    Working...