how to call a vb6 standalone exe module function from c/c++ new thread-reg
Dear Trick,
I have gone thru all your examples in multithreading and interacted with you by which you clarified me how to use them.
We know that any c/c++ dll can interact with vb6 standalone exe thru module callback function using addressof operator.The c/c++ dll can export a function using .def file which takes callback function as parameter.
In the exported function we can execute the module function passed vb6 function pointer as parameter.The module function in this vb6 standalone exe can display for example a simple msgbox.
Can you show me a working example of how to call a vb6 standalone exe module function from exported function in which new thread is created in c/c++ dll so that it can also be included in the code bank for which I shall be grateful to you.
Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg
Brothers worked hard, and it took a year and a half to see your speech again. I know you are not guilty and you are finally free. In fact, multithreading in VB6 is really hard, but we old VB developers don't want to give it up.
Multi-threading is realized in EXCEL VBA, multi-threading is realized in standard DLL, and multi-threading in ACTIVEX.EXE.
And VC++ calls the standard DLL written in VB6, and the VB function in it also needs to initialize the VB header, so it runs normally.
Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg
Dear Trick,
The sample requested by me is interaction between
vb6 standard exe and c/c++ dll where the vb6 exe module function is executed by c/c++ dll exported function by accepting module function pointer as parameter.
The vb6 standard exe contains a module function which displays a simple msgbox.
The c/c++ dll can be either
1.standard dll exporting a function which takes a function pointer as parameter so that it can accept vb6 standard exe module function as parameter and executes it in new thread created using CreateThread API.
or
2.activex dll exporting a class member function which takes a function pointer as parameter so that it can accept vb6 standard exe module function as parameter and executes it in new thread created using CreateThread API.
None of the examples mentioned has c/c++ dll exporting function which tries to execute in new thread the module function of vb6 standard exe.
Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg
Originally Posted by The trick
InternetCallback is called from wininet.dll.
Dear Trick,
I am sending the sampleproject.zip as attachment.It contains both c dll and vb exe projects.Only thing is we have to see that both c dll and vb6 exe are in same directory after building the projects.
The c dll exports callfunctionpointer function which accepts function pointer as parameter to which we give MyCallbackfunction module function as parameter using addressof operator when we click on vb6 exe project displayed form callfunctionpointer button.The Callfunctionpointer function after accepting the vb module function creates a new thread using CreateThread API and tries to execute the vb6 callback.Wherever required the vb6 application uses your modmultithreading2.bas.Here vb6 app crashes when I click on vb6 form button.
regards,
JSVenu
Last edited by jsvenu; Oct 17th, 2021 at 12:21 AM.
Reason: forgot to initialize and uninialize modmultithread in form load and unload now updated
Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg
Originally Posted by jsvenu
Dear Trick,
I am sending the sampleproject.zip as attachment.It contains both c dll and vb exe projects.Only thing is we have to see that both c dll and vb6 exe are in same directory after building the projects.
The c dll exports callfunctionpointer function which accepts function pointer as parameter to which we give MyCallbackfunction module function as parameter using addressof operator when we click on vb6 exe project displayed form callfunctionpointer button.The Callfunctionpointer function after accepting the vb module function creates a new thread using CreateThread API and tries to execute the vb6 callback.Wherever required the vb6 application uses your modmultithreading2.bas.Here vb6 app crashes when I click on vb6 form button.
regards,
JSVenu
This is the last time i write - please read carefully the example. You just don't read the module description. When you'll have a trouble using the module description you can write here i'll help.
Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg
Dear Trick,
I followed the steps as in InternetCallback sample and used InitCurrentThreadAndCallFunction of modmultithreading module properly and finally resolved the crash problem.As usual I thankyou very much with due respect for your sincere guidance and patience.
Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg
Any EXE or DLL written in VC++ can be called (standard DLL written in VB6, or exported function in standard EXE), but the export function in VB6 needs to initialize the vb header, otherwise MSGBOX cannot be used, or even windows api cannot be called , Such as findwindow
Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg
Originally Posted by jsvenu
Dear Trick,
I followed the steps as in InternetCallback sample and used InitCurrentThreadAndCallFunction of modmultithreading module properly and finally resolved the crash problem.As usual I thankyou very much with due respect for your sincere guidance and patience.
Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg
Hello Trick,
but when I added __stdcall to async and added the following and tried in async.cpp without using .DEF file
#pragma comment (linker, "/EXPORT:async=_async@4")
Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg
Originally Posted by smkperu
Hello Trick,
but when I added __stdcall to async and added the following and tried in async.cpp without using .DEF file
#pragma comment (linker, "/EXPORT:async=_async@4")