CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2001
    Location
    Dallas, TX
    Posts
    9

    Problem passing pointer to dll

    I have a VB program that calls a C++ dll and passes it a pointer to a byte.

    I been able to make everything else work, the handles, strings, all of those, but when trying to pass a pointer I get a vb6.exe error saying the memory could not be read. I don't think it has anything to do with the C dll because I commented out all of the code inside the function to see if it was in there and still got the same problem.

    I have a byte variable, I'm sending it byref and the c dll is supposed to write to that address.

    Any ideas?

    thank in advance


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: Problem passing pointer to dll

    try declare the parameter as any


    HTH

    cksiow
    http://vblib.virtualave.net - share our codes

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

    Re: Problem passing pointer to dll

    You could try declaring it
    byval lpByte as Long

    and in the call, passing VarPtr(btMyVariable)

    ?

    -------------------------------------------------
    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<------------------------------------------

  4. #4
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Problem passing pointer to dll


    Declare YourCFunction(byval bParm as byte) as whatever

    private Sub CallFunction()
    dim bVar(100) as byte
    dim ret as whatever
    ret = YourCFunction(bvar(0))
    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