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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLL HELP

Status
Not open for further replies.

delali

Programmer
Aug 20, 2001
8
US
I am a summer intern and I have a few questions on my summer project.

I have some VC++ code that I would like to be able to call in VB.NET. What I am attempting to do is while the VC++ code is running I would like to periodically extract some data to be plotted and viewed in a VB interface. I am not sure what that best means of approach is for this. People have given many suggestions, but as I have never interfaced VB and VC before I am getting a little confused and am not sure what advice to listen too.

It was suggested to me that I could create a DLL with the VC++ code that would be called in VB, but in my research and in all of the examples that I have seen it seems as though a DLL is used to call functions from different programs, is this true? Will I be able to have the VC++ code running and extract data if I create a DLL?

It was also suggested that I use the LoadLibrary function, but I am not sure exactly what that is used for or how to use it.

I appreciate any help that anyone can give me, to help steer me in the correction direction.


Thanks!
Delali Dzirasa
PS I don’t know if this is needed but I am running on W2K, and VC++ 6.0, where the current application is compiled as an EXE console application.


 
Is the c++ program something that needs to run independently of the vb interface?
 
No it does not, currently the EXE is in VC++ in a console app, I do not need to see that, but as it gathers/manipulates data I would like to be able to capture that data in real time to be displayed in VB.


Delali
 
Well, not needing to see the console does not mean that the program does not need to run independently of the VB interface.

When you say things like "as it gathers/manipulates data", it sounds like the C++ program needs to remain running "in the background" even when you close the VB interface.

Is that the case?
 
>When you say things like "as it gathers/manipulates data", >it sounds like the C++ program needs to remain running "in >the background" even when you close the VB interface.

>Is that the case?

No, that is not the case I will have a button that starts/launches the C++ code from VB then I will have a button that close it from VB.

Delali
 
Ok, so you could do a dll. Apparently VB can load dlls. Instead of "LoadLibrary" which is the C/++ function call to load a dll, you use "Declare" and "Lib". I looked around for a minute and there seem to be a lot of links which deal with this topic. Here's one:


I think everything you need (in principle) is covered there. Thing is, you have to understand enough C++ to take your console app code and make a dll out of it (especially since it sounds like there's some state maintenance and threading going on). If you don't, then you need to get up to speed on writing a basic dll. (try Petzold's "Programming Windows" chapter 21).

Good luck.
 
Why you people are discussing over these things, just use ALT-COM wizard in VC++6 to generate a COM Based DLL. Then in your VB application you can add the dll as a reference and used any functionality.

Rahul If you think you can't do it,You will never be able to do it.
 
Thanks, I will read up on the COM based DLL and give it a try...thanks again for the input!

Delali
 
RahulGade:

Sure. ATL away! I was just following his lead out of curiosity.

Keep in mind however, if you do a COM object you gotta register it on any other machine than the one you built it on (ask people to do regsvr32 or give them a batch file).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top