Valhalla Legends Forums Archive | Visual Basic Programming | Call VB6 function from a DLL

AuthorMessageTime
LivedKrad
Is there any way to call a function contained within a VB6 EXE from a VB6 DLL? I've already create a Standard DLL with VB6, with exportable functions. However now, I'd like to import functions to the DLL from the loading executable. Is this possible?
April 4, 2006, 10:00 PM
TheMinistered
there are certain hacks you can do to the compiler (hooking it before it's finished and changing intermediary code...) but, I think I might know of a way to do it with pure vb code.
April 4, 2006, 10:05 PM
LivedKrad
Eh, but using pure VB code would involve COM/ActiveX executables would it not?
April 4, 2006, 10:18 PM
warz
So, you're making a VB application that uses a VB dll, but want to avoid using VB code to call functions from within the application?
April 5, 2006, 12:59 AM
JoeTheOdd
If you wrote a standard DLL (that exports functions like a C++ or ASM DLL), then all you have to do is declare the header line.

[tt]Declare functName(ArgName As ArgType, ...) As retType[/tt]

It can be private or public, but I trust you know scopes by now.
April 5, 2006, 1:46 AM
UserLoser
[quote author=LivedKrad link=topic=14692.msg149781#msg149781 date=1144188048]
Is there any way to call a function contained within a VB6 EXE from a VB6 DLL? I've already create a Standard DLL with VB6, with exportable functions. However now, I'd like to import functions to the DLL from the loading executable. Is this possible?
[/quote]

Pass the address of the function to the DLL then call it.  Simple enough, see AddressOf operator
April 5, 2006, 5:10 AM
TheMinistered
But passing via AddressOf will not avoid a COM call if the fxn is located inside an Object.  It just bypasses creation of the object.

It seems somewhat redundant to comile a standard dll via vb (linker hack) just to use the dll from a vb exe.  Why not just use an ActiveX dll?

Seems like there would be way more overhead in doing so... probably simpler to load the activex dll and pass an object to it, because your going to have way more overhead in calling that fxn address.
April 5, 2006, 6:12 AM
JoeTheOdd
Although this is completely unrelated (I think?), how do you use an ActiveX DLL in VB?
April 5, 2006, 7:22 PM
Topaz
You reference it or add it as a control.
April 5, 2006, 10:40 PM
Ringo
[quote author=LivedKrad link=topic=14692.msg149781#msg149781 date=1144188048]
Is there any way to call a function contained within a VB6 EXE from a VB6 DLL? I've already create a Standard DLL with VB6, with exportable functions. However now, I'd like to import functions to the DLL from the loading executable. Is this possible?
[/quote]
Yeah, just use a activeX.exe and a activeX.dll project (as group project if u want), then link the exe to the dll via project > references > browse > exe/dll and then add the exe.

But i dont think you can then link the dll to the exe on top of that, because VB doesnt allow cyclic references.
Or just use good old events :)

Hope this helps.
April 5, 2006, 10:49 PM
LivedKrad
[quote author=Topaz link=topic=14692.msg149902#msg149902 date=1144276824]
You reference it or add it as a control.
[/quote]

That would defeat the purpose of having non-COM libraries use the functions in my executable as well. So, there's no non-COM way to do this? Perhaps I could use Events like Ringo said to have the executable catch events fired by the DLL?
April 7, 2006, 5:54 PM
Myndfyr
I don't have VB6 on here to try this, but can't you create a function in the DLL that accepts a function as a parameter a la AddressOf (someone else said this), so you more or less "register" EXE functions with the DLL?
April 7, 2006, 6:37 PM
TheMinistered
Events are part of COM... maybe you should do some more research on this entire subject and maybe you will see why I said making a standard dll in vb and then loading it via a vb executable and passing a fxn addr is redundant.  In fact, why don't you research COM because I think we all know how standard dlls work.
April 7, 2006, 8:39 PM
LivedKrad
Maybe.
April 9, 2006, 1:42 AM
ntaryl
Hi  again 
Maby this  link  help  u 
http://www.vb-helper.com/howto_make_standard_dll.html
see  the way how to call function from a standalone .dll
Sorry if iam Wrong 
thanks 
March 12, 2007, 2:56 PM
rabbit
Stop reviving old threads.
March 12, 2007, 4:04 PM

Search