Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 18th, 2004, 04:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: McPherson, Kansas, USA.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default Calling an ActiveX.EXE in C++

Hopefully, you all can at least point me in the right direction. I have several ActiveX exe's written in VB 6.0. Now, I am working with some legacy app's in C ++ and I want to be able to reuse that code through automation. Does anyone know how to do that or can you point me in the right direction?

Thanks in advance,



Larry Asher
__________________
Larry Asher
Reply With Quote
  #2 (permalink)  
Old February 18th, 2004, 05:17 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: , , .
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My hunch is an activeX exe would be called much the same way a COM dll would be called as in regards to COM an ActiveX dll and an ActiveX exe should be the same. However, this is really a question to be asked in a C++ group.
Reply With Quote
  #3 (permalink)  
Old February 18th, 2004, 05:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: McPherson, Kansas, USA.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well the topic is posted there as well. I am not convinced it is specifically a C++ question. However, I do feel that is more than likely the same as calling a DLL which I am looking into now. But, I do not want to go on assumptions.

Thanks for your reply.

Larry Asher
Reply With Quote
  #4 (permalink)  
Old February 18th, 2004, 05:44 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: , , .
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I only refer you to a C++ group because my C++ syntax is out of date (I haven't done anything in C or C++ in 5 years). In VB it is the same as calling a COM dll, hence, my assumption that it should work the same in C++.

Yehuda
Reply With Quote
  #5 (permalink)  
Old February 18th, 2004, 08:22 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There are few ways to do so. The one I remember is this.
Let's suppose you want to call the method ShowMe of the class CTest of the library PTextP (this is one of my test application)

Open the stdafx.h file and add these lines

#import "PTestP.dll"
using namespace PTestP;

just before the last endif, and compile the project (the dll must be in a known path). The compiler will generate some import files from the type library of PTestP.

Now it is easy:

HRESULT hresult;
CLSID clsid;

hresult = CLSIDFromProgID(OLESTR("PTestP.CTest"), &clsid);

_CTest *ctest;
hresult=CoCreateInstance(clsid,NULL,CLSCTX_INPROC_ SERVER,__uuidof(_CTest),(LPVOID *) &ctest);
if(FAILED(hresult))
{
  // do something here
  return;
}

ctest->ShowMe();
ctest->Release();
Reply With Quote
  #6 (permalink)  
Old February 19th, 2004, 10:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: McPherson, Kansas, USA.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the input Marco.

I am in the process of testing some ActiveX components now. It seems that I have ran into yet another issue which I anticipated but am having very little luck in finding a solution. That is passing a string variable. The COM interface is requesting a variable type BSTR. I have tried using _bstr_t to create a variable but the compiler does not like it. The documentation is not very helpful and this will likely be my next post. Sounds like you may have some experience with this. I would appreciate any help you could offer.

Just one more thing. It seems that VB developers often take some flake especially from the C/C++ developers. I work in a shop where all of the legacy apps are in C/C++ and much of the new development I am doing in VB migrating to .NET. However, most of my C++ post go unanswered which is a direct contrast to my VB post. There just seems to be so many more resources available to the VB developers that really increase the productivity level. I really think that C has its place but from all of the applications I have been exposed to you could accomplish the same thing in VB with a whole lot less effort. It looks like .NET is going to level the playing field and for that I am grateful.

Thanks.

Larry Asher
Reply With Quote
  #7 (permalink)  
Old February 19th, 2004, 05:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

We are very welcome.

I need more info. Are you creating the string in the VB or in the C code? Does it need to be modified in the project where it was not created?

Regarding the diatribe C versus VB, I think it is a very stupid one. They are just two programming languages, and any seriuos professional will never work only with one language. VB is great for user interface and data base access, but it does not have native multi threads supports and subclassing. Any professional will always pick the right language for the job. And I do not think .NET will be a solution, in a way (like adding the new C# language and creating a heavier environment) it will make things worst.

Marco


Quote:
quote:Originally posted by xgbnow
 Thanks for the input Marco.

I am in the process of testing some ActiveX components now. It seems that I have ran into yet another issue which I anticipated but am having very little luck in finding a solution. That is passing a string variable. The COM interface is requesting a variable type BSTR. I have tried using _bstr_t to create a variable but the compiler does not like it. The documentation is not very helpful and this will likely be my next post. Sounds like you may have some experience with this. I would appreciate any help you could offer.

Just one more thing. It seems that VB developers often take some flake especially from the C/C++ developers. I work in a shop where all of the legacy apps are in C/C++ and much of the new development I am doing in VB migrating to .NET. However, most of my C++ post go unanswered which is a direct contrast to my VB post. There just seems to be so many more resources available to the VB developers that really increase the productivity level. I really think that C has its place but from all of the applications I have been exposed to you could accomplish the same thing in VB with a whole lot less effort. It looks like .NET is going to level the playing field and for that I am grateful.

Thanks.

Larry Asher
Reply With Quote
  #8 (permalink)  
Old February 19th, 2004, 05:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: McPherson, Kansas, USA.
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hey, thanks for your help but I was able to resolve the problems and have that working.

I do appreciate you help. But, I am not sure how to take your comment "Regarding the diatribe C versus VB, I think it is a very stupid one ..." I can't tell if your directing that towards me or speaking in general.

Thanks.

Larry Asher
Reply With Quote
  #9 (permalink)  
Old February 19th, 2004, 06:11 PM
Friend of Wrox
 
Join Date: Aug 2003
Location: , , .
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Interesting comment, Marco. Why do you think VB.NET is worse? Having worked with both, I can honestly say that while I miss the IDE of VB6 and a few other small things .NET appears to be more efficient and stabler as a whole than VB 6.0. And while I don't think VB.NET is yet the equivalent of C++ in all regards it certainly came a long way on some of defficiencies of VB 6.0.
Reply With Quote
  #10 (permalink)  
Old February 19th, 2004, 07:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Alameda, ca, USA.
Posts: 627
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Larry, I am sorry for the confusion, for sure I did not mean you are stupid! I just find pointless reading articles and articles about which language is better than the other...

Yehuda, .NET is definitevely a step forward the old VB6, even though I am migrating to C# (beeing an old C programmer myself), and we are already reading too much about C# is better, no it is VB.NET , no no I am right and you are wrong). But we pay a price with .NET: we have to deal with a big infrastructure, big applications and big libraries. We hardcore VB programmers know the VB limitation: it is great because it hides the Windows internal, it is bad because it hides just that feature needed for that application (for example, no Move event, and no way to know the exposed area in the Paint event) .NET hides even more, thus I foresee a lot of unmanaged C code...

Using C++ and ATL was possible to write small and efficient Windows servers. With DevStudio it is even possible to write and compile C code for real time operative systems. .NET was designed mainly for internet applications, where you do not know in what computers your code will run, can be a PC or a microwave. But the world is not only internet, and it is not going to be any time soon.

Marco
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connecting to an ActiveX exe Tweety77 VB How-To 4 September 19th, 2006 01:21 PM
ActiveX.exe to standard exe Kaustav VB How-To 6 February 24th, 2006 12:10 AM
Calling an ActiveX.EXE in C++ xgbnow Visual C++ 4 March 31st, 2004 08:12 AM
unregister activeX exe gbianchi Pro VB 6 2 February 10th, 2004 03:17 PM
ActiveX Exe and Dll Vasudevan VB How-To 1 September 26th, 2003 07:48 AM



All times are GMT -4. The time now is 04:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.