VB2005 Short address pointer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Galen Somerville

    #1

    VB2005 Short address pointer

    A call to a third party dll, which will call back, requires an hWnd and a 16
    bit sub address. Yes this was designed for VB6.

    Addressof and delegates and all that good crap doesn't help.

    The hWnd where the subroutine is located is no problem. But how can I
    provide the subroutines address as a Short ??

    GalenS




  • Mattias Sjögren

    #2
    Re: VB2005 Short address pointer

    >A call to a third party dll, which will call back, requires an hWnd and a 16[color=blue]
    >bit sub address. Yes this was designed for VB6.[/color]

    VB6 also targets Win32 so I don't see how it could work there.

    [color=blue]
    >The hWnd where the subroutine is located is no problem. But how can I
    >provide the subroutines address as a Short ??[/color]

    If you're running .NET 2.0 you can try calling
    Marshal.GetFunc tionPointerForD elegate(), truncate the result to
    16-bits and see if it works.


    Mattias

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

    Comment

    • Galen Somerville

      #3
      Re: VB2005 Short address pointer


      "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rg> wrote in message
      news:OPyyfPgbGH A.4892@TK2MSFTN GP02.phx.gbl...[color=blue][color=green]
      > >A call to a third party dll, which will call back, requires an hWnd and a
      > >16
      >>bit sub address. Yes this was designed for VB6.[/color]
      >
      > VB6 also targets Win32 so I don't see how it could work there.
      >
      >[color=green]
      >>The hWnd where the subroutine is located is no problem. But how can I
      >>provide the subroutines address as a Short ??[/color]
      >
      > If you're running .NET 2.0 you can try calling
      > Marshal.GetFunc tionPointerForD elegate(), truncate the result to
      > 16-bits and see if it works.
      >
      >
      > Mattias
      >
      > --
      > Mattias Sjögren [C# MVP] mattias @ mvps.org
      > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      > Please reply only to the newsgroup.[/color]

      My bad. In VB2005 it would be integer not short

      VB6 code in bas module. The Call SetEventTable is immediately followed by
      the 3rd party dll call WDU_Init

      Dim eventTable As WDU_EVENT_TABLE

      Call SetEventTable(e ventTable, AddressOf DeviceAttach, AddressOf
      DeviceDetach)
      eventTable.pUse rData = WD_VB_GetAddres s(DevCtx, 1, 1)

      dwError = WDU_Init(hdrive r, matchTable, 1, eventTable, _
      DEFAULT_LICENSE _STRING, WD_ACKNOWLEDGE, hWnd)

      VB6 driver code bas module. It would appear that the AddressOf's could be
      left out of the SetEventTable call and placed directly after the ='s below.

      Public Sub SetEventTable(B yRef eventTable As WDU_EVENT_TABLE , ByVal attachCb
      As Long, _
      ByVal detachCb As Long)
      eventTable.pfDe viceAttach = attachCb
      eventTable.pfDe viceDetach = detachCb
      End Sub

      Public Type WDU_EVENT_TABLE
      pfDeviceAttach As Long
      pfDeviceDetach As Long
      pfPowerChange As Long
      pUserData As Long
      End Type


      VB6 declares for callback procedures

      Public Function DeviceAttach(By Val hDevice As Long, ByRef pDeviceInfo As
      WDU_DEVICE, _
      ByRef pUserData As DEVICE_CONTEXT) As Boolean
      Public Sub DeviceDetach(By Val hDevice As Long, ByRef pUserData As
      DEVICE_CONTEXT)

      GalenS


      Comment

      Working...