Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 23rd, 2006, 05:09 AM
Authorized User
 
Join Date: Feb 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I connect to a specific object?

Hi

I have a vb6 application that can create multiple instances of an emulator (one for automatic data transfer from machinery and the other for manual entry).

In the GetObject function you can only supply the path or class which will be the same for both instances. The captions/title will, however be different

How can I ensure I connect to the correct instance?

Thanks in advance

Daz


 
Old November 28th, 2006, 03:09 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Create the instances from within VB, which puts a reference to the running code in an object.

Using APIs you can "read" the titlebars of the windows (seems to me there's an API to enumerate the running appls), and get the hWnd of those windows. More work than the first suggestion though.

(BTW: using GetObject doesn't connect you to anything, it only returns a reference to the running object. You use this connection to communicate with it, but there is no connection, per se.)

Perhaps http://p2p.wrox.com/topic.asp?TOPIC_ID=11222 would be helpful...
 
Old November 28th, 2006, 03:36 PM
Friend of Wrox
 
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is your emulator written in VB6?

Using GetObject requires that the object you are getting is registered in the Running Object Table (generally referred to as the ROT). And applications written in VB6 are not added to the ROT, and therefore you CANNOT use GetObject to get a running object of a component written in VB6, or any component that does not cause itself to be entered into the ROT. You can code a VB6 app to register itself in the ROT, but it should be considered an advanced level programming task - you'll need to gather the knowledge you need and experiment a lot.

So... The question is: Is your emulator written in VB6, or in some other language? Is it an ActiveX exe or dll?


Woody Z http://www.learntoprogramnow.com
 
Old November 29th, 2006, 09:53 AM
Authorized User
 
Join Date: Feb 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks guys, I have used Brians first suggestion and keep the object alive. Just had to add a few checks in case the emulator had been destroyed outside of the VB app.

Thanks again.

Daz






Similar Threads
Thread Thread Starter Forum Replies Last Post
Search specific data from specific columns yogeshyl SQL Language 1 January 16th, 2008 11:12 AM
Copy specific data in specific cells of sheet2 yogeshyl Excel VBA 1 May 14th, 2007 07:40 AM
Serializing Object Graph - Assigning Object to Jag venkat.kl C# 0 August 28th, 2006 10:39 AM
create a Line object ,Box object in CR at Runtime? thanhnt Pro VB 6 1 May 16th, 2005 06:51 AM
Error Occurred creating Report Object: Object does sa_moizatyahoo Classic ASP Professional 0 February 1st, 2005 10:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.