Results 1 to 21 of 21

Thread: how to call a vb6 standalone exe module function from c/c++ new thread-reg

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    356

    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.

    regards,
    JSVenu

  2. #2
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    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.

  3. #3

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    356

    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.

    regards,

    JSVenu

  5. #5

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    356

    Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg

    Quote Originally Posted by The trick View Post
    Please read carefully. InternetStatusCallback is called from C/C++ dll in arbitrary thread.
    Dear Trick,

    I have gone thru InternetStatusCallback folder of the link and I could not find c/c++ dll.The InternetStatusCallback is vb6 standard exe project.

    regards,
    JSVenu

  7. #7

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    356

    Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg

    Quote Originally Posted by The trick View Post
    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
    Attached Files Attached Files
    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

  9. #9

  10. #10
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,673

    Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg

    Quote Originally Posted by jsvenu View Post
    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.

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    356

    Resolved 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.

    regards,
    JSVenu

  12. #12
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    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

  13. #13
    Addicted Member
    Join Date
    Dec 2021
    Posts
    144

    Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg

    Quote Originally Posted by jsvenu View Post
    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.

    regards,
    JSVenu
    Hello jsvenu,

    Can you send me the working code.

    Thanks

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2015
    Posts
    356

    Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg

    Dear peru,

    code link attached

    regards,
    jsvenu
    Attached Files Attached Files

  15. #15
    Addicted Member
    Join Date
    Dec 2021
    Posts
    144

    Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg

    Hello jsvenu,


    Thanks

  16. #16
    Addicted Member
    Join Date
    Dec 2021
    Posts
    144

    Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg

    Hello Trick,

    Please clear space for sending PM.
    Thanks

  17. #17

  18. #18
    Addicted Member
    Join Date
    Dec 2021
    Posts
    144

    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")

    extern "C" __declspec(dllexport) void __stdcall async(long addr)

    and finally use async in vb6 std exe it crashes

    Thanks

  19. #19

  20. #20
    Addicted Member
    Join Date
    Dec 2021
    Posts
    144

    Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg

    Hello Trick,

    Ok. Now this works only in native compiled code .
    I have sent you a PM.

    Thanks.

  21. #21
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,116

    Re: how to call a vb6 standalone exe module function from c/c++ new thread-reg

    Quote Originally Posted by smkperu View Post
    Hello jsvenu,

    Can you send me the working code.

    Thanks
    Quote Originally Posted by jsvenu View Post
    Dear peru,

    code link attached

    regards,
    jsvenu
    Quote Originally Posted by smkperu View Post
    Hello jsvenu,


    Thanks
    LOL - we all know you operate both accounts, no need for the fake "handing off the question from one account to the other" posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width