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.
Printable View
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.
The problem is, VB can't do this, because normally, you'd do this:
...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.Code:Dim hMod as Long
Dim hPrc as Long
hMod = LoadLibrary("file.dll")
hPrc = GetProcAddress(hMod, "GetData")
Why cant i use what you put ?
Because I don't think VB can use function pointers (*sob*).
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.
What would be the Declares to use LoadLibrary and GetProcAddress ??
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
Which DLL from PSC are you using?
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.
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:
...where CallMyFunc does:Code:Private Declare Function CallMyFunc(ByVal sModule As String) As Long
Private Sub DoStuff()
Debug.Print CallMyFunc("addin_a.dll")
End Sub
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.
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 ?
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.
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.
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 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