|
-
Sep 26th, 2000, 12:13 PM
#1
Thread Starter
Frenzied Member
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.
-
Sep 26th, 2000, 12:53 PM
#2
Monday Morning Lunatic
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
-
Sep 27th, 2000, 02:56 PM
#3
Thread Starter
Frenzied Member
Why cant i use what you put ?
-
Sep 27th, 2000, 02:59 PM
#4
Monday Morning Lunatic
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
-
Sep 27th, 2000, 03:22 PM
#5
Thread Starter
Frenzied Member
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.
-
Sep 27th, 2000, 03:24 PM
#6
Thread Starter
Frenzied Member
What would be the Declares to use LoadLibrary and GetProcAddress ??
-
Sep 27th, 2000, 03:26 PM
#7
Thread Starter
Frenzied Member
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
-
Sep 28th, 2000, 12:48 PM
#8
Monday Morning Lunatic
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
-
Sep 29th, 2000, 03:07 PM
#9
Thread Starter
Frenzied Member
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.
-
Sep 29th, 2000, 03:49 PM
#10
Monday Morning Lunatic
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
-
Sep 29th, 2000, 04:19 PM
#11
Thread Starter
Frenzied Member
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 ?
-
Sep 29th, 2000, 05:28 PM
#12
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.
-
Sep 29th, 2000, 10:59 PM
#13
Frenzied Member
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.
-
Sep 30th, 2000, 04:00 AM
#14
Monday Morning Lunatic
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
-
Sep 30th, 2000, 07:44 AM
#15
Thread Starter
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|