Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing a DLL in C++ for use in a Visual Basic Progam

Status
Not open for further replies.

nhungr

Programmer
Jan 31, 2005
26
CA
I have a C++ program that does a long set of calculations for up to 45 minutes. At periodic intervals during the calculations, it outputs some values and comments.

Is it possible to turn this program into a Dynamic Link Library (DLL) and then run it from a Visual Basic interface. I was thinking that the VB interface would call the main() function in the DLL, and then the DLL would output the periodic data back to the VB interface. Is this possible? How easy is it to do? Where could I find some information on this topic?

Any help would be much appreciated. Thanks,

Nikolai.
 
A more professional (and challenging approach) would be not to write a simple library (.dll) but a COM object (an in-process COM server would suffice).
You should use the multi-threaded apartment (MTA) threading model ( ) and from this point onward you have two options:
1) periodically call a method implemented by the COM interface to retrieve specific data (remember that you can call a method in the COM while another is running (i.e performing your calculations) - also take care of the multi-threaded synchronizations);
2) use connection points to notify the VB application ( )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top