• Welcome to Valhalla Legends Archive.
 

Call VB6 function from a DLL

Started by LivedKrad, April 04, 2006, 05:00 PM

Previous topic - Next topic

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?

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.

LivedKrad

Eh, but using pure VB code would involve COM/ActiveX executables would it not?

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?

Joe[x86]

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.

Declare functName(ArgName As ArgType, ...) As retType

It can be private or public, but I trust you know scopes by now.
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

UserLoser

Quote from: LivedKrad on April 04, 2006, 05:00 PM
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?

Pass the address of the function to the DLL then call it.  Simple enough, see AddressOf operator

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.

Joe[x86]

Although this is completely unrelated (I think?), how do you use an ActiveX DLL in VB?
Quote from: brew on April 25, 2007, 07:33 PM
that made me feel like a total idiot. this entire thing was useless.

topaz

You reference it or add it as a control.
RLY...?

Ringo

Quote from: LivedKrad on April 04, 2006, 05:00 PM
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?
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.

LivedKrad

Quote from: Topaz on April 05, 2006, 05:40 PM
You reference it or add it as a control.

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?

MyndFyre

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?
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

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.


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 
Code or Die 
Warez Lover For ever
Google my best Friend after JK