Results 1 to 12 of 12

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
    342

    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
    Frenzied Member
    Join Date
    Jan 2020
    Posts
    1,635

    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
    342

    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
    342

    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
    342

    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
    Frenzied Member
    Join Date
    Feb 2015
    Posts
    1,849

    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
    342

    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
    Frenzied Member
    Join Date
    Jan 2020
    Posts
    1,635

    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

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