Results 1 to 15 of 15

Thread: DLL Load

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    Im making an app that has a Add-In thing. If all of the add-in dlls have a function called GetData() then how can i make it run that function from a selected dll in a list.

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The problem is, VB can't do this, because normally, you'd do this:
    Code:
    Dim hMod as Long
    Dim hPrc as Long
    hMod = LoadLibrary("file.dll")
    hPrc = GetProcAddress(hMod, "GetData")
    ...unfortunately, you have a function pointer, not a function itself. What I would suggest is having an extra DLL that you pass the pointer to, which will call the function for you and return the result.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    Why cant i use what you put ?

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Because I don't think VB can use function pointers (*sob*).
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    Ive got another app that will only work if in the source u change the dir to the correct one so i think u may, im trying it now so.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    What would be the Declares to use LoadLibrary and GetProcAddress ??

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    My Code For The Other Project I Got Of Planet-Source-Code

    'Replace X's with the correct path and filename of the dll.

    Public Declare Sub InstallHook Lib "X" (ByVal hWnd As Long)

    Public Declare Sub RemoveHook Lib "X" ()

    I presume Remove and InstallHook are functions in the DLL

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Which DLL from PSC are you using?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    The dll im using that i got those declase from is a keyboard hook that gets every single key u press on the jeyboard and sends it to a textbox, but i want to make my ownd dll add in thing whereby u create several dlls and then my app can just load up one and run a function in it. The function always has the same name.

  10. #10
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    If you give me full specifications of the functions you want the extra DLLs to export, then I'll write a small 'handler' DLL, which would work something like this:
    Code:
    Private Declare Function CallMyFunc(ByVal sModule As String) As Long
    Private Sub DoStuff()
        Debug.Print CallMyFunc("addin_a.dll")
    End Sub
    ...where CallMyFunc does:
    1. Load sModule
    2. Get function pointer for your function
    3. Call function
    4. Return returned value to VB program

    How's that sound? I'll be on Yahoo! if you want to discuss more.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  11. #11

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    The app i want to return the string to in my main app is called : strData

    the function in the add-in slls will be called

    Option Explicit

    Private strText as String

    Public Function GetText() as String
    GetText = strText
    end Function

    Public Function SetText(strTextToPut as string)
    strText = strTextToPut
    end function

    Right, thats the dll, p:s can u send me the source to what u write ?

  12. #12
    Guest
    The type of DLL you need can't be created using VB. VB can only create ActiveX DLLs.
    If you want to create the DLL use C++/VC++ to do it.

  13. #13
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Ah, but DLLs can be done in VB. The code and steps is fricken huge, and takes all kinds of hacks and back doors, but its cool. Visual Basic Programmer's Journal http://www.vbpj.com/ has published articles on this--very neat stuff. But it may not be worth your effort.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  14. #14
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Yeah, it's possible (it's also possible to link C++ and VB code together), but difficult. I really have to say it here - don't try and do anything clever with DLLs in VB. It's much more effort than it's worth - it's easier to learn C++ and make one that way. Also, the people writing the addin DLLs will most likely be using C++.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  15. #15

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    I do posses a copy of VC++ 6 so im able to do it in VC++ but not sure on what code as im a beginner. I know how to create dlls and to put a fucntion into it but not sure on the code for the dll

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