CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2001
    Posts
    4

    callback from C dll

    in our app we r interacting with c dll's provided by the third party vendor.
    to reference the dll we are using 'public declare'. there is one function in the dll which does a callback to one of our vb procedure. we pass the address of this vb procedure as an argumant to the dll function.
    when the callback comes general exception error is raised 'Cannot write to memory'
    thanks in advance


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: callback from C dll

    You need to post the TypeDef, Declare statement and Function that you are passing for us to have any hope of helping you.

    HTH,
    D.

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Oct 2001
    Posts
    4

    Re: callback from C dll

    typedef struct _MTDAC_EVENT {
    ULONG Status;
    DWORD TimeStamp;
    ULONG EventCode;
    ULONG SubReason;
    ULONG Board;
    ULONG Channel;
    ULONG UserEvent;
    PVOID UserData;
    } MTDAC_EVENT, *PMTDAC_EVENT;

    ULONG MTDACStartLink(MTDAC_EVENT_CALLBACK callback);

    The above is as documented by the third party vendor

    And following is our VB Declarations

    Public Type MTDAC_EVENT
    Status As Long
    TimeStamp As Long
    EventCode As Long
    SubReason As Long
    Board As Long
    Channel As Long
    UserEvent As Long
    UserData As Long
    End Type

    Private Declare Sub ExecuteCallback Lib "vcvbnew.dll" (ByVal fnName As Long)

    Call ExecuteCallback(AddressOf MyFunction)

    Public Sub MyFunction(MTDAC As MTDAC_EVENT)
    MsgBox "Channel : " & MTDAC.Channel
    MsgBox "Event : " & MTDAC.EventCode
    End Sub


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured