Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > Visual C++
|
Visual C++ Questions specific to Microsoft's Visual C++. For questions not specific to this Microsoft version, use the C++ Programming forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual C++ 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 August 5th, 2004, 03:28 AM
Registered User
 
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Passing clas by reference

How to pass a class by reference between two dll's (COM Comp)??? or a pointer to an COM component object which is defined in some other dll to another dll??

Thanks in Advance

Regards,

ThunderBird
 
Old August 5th, 2004, 03:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Are you writing both the dlls?
Is one of the dlls acting as a client and using the other as server?

If thats the case then you have to do things like define the class in the IDL of the server and give it a GUID so that any client can recognize it. etc.

Just give some more details as to what you are doing.

Ankur
 
Old August 5th, 2004, 06:14 AM
Registered User
 
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Suppose there are three dll's A,B and C. I want to pass a class (X)defined in C from A to B. Something like this

From A

B->xyz (ptr to class in C)

In B I want to use functions defined in the class X.

Any ides??

Is it possible to transfer ptr to non native data types across com components.

 
Old August 5th, 2004, 07:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default



Is it a perticular requirement that you define the class in a separate enitiy (DLL C). Why not simply define it in A and pass it to B.

There may be other solutions to you problem like use of monikers where you can create an instance only once and share it among apps but I'm still not sure what you r trying to do.
 
Old August 6th, 2004, 05:46 AM
Registered User
 
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ankur,

Can we pass and use the Interface pointer of one COM to other COM component. If yes please let me know how to achive this. I believe we can pass something like this

A->xyz(IC** S)

XYZ(IC** S)
{
}
Is it correct and now how to use it to access functions in S.

Thanks in Advance

Regards,

ThunderBird

 
Old August 6th, 2004, 06:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

See to do this you dont have to do anything just treat one of the COM dlls as server and do CoCreateInstance from the client DLL for server's primary interface and then access anyother interface defined in it using QueryInterface .

If you need to PASS a pointer thats possible too becuase your client DLL will be able to recognize the interface thats being passed as long as it is duely defined in the server DLL just like the other interfaces.

Regards
Ankur Verma





Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing by reference quiksilverhg Excel VBA 5 November 21st, 2005 03:49 AM
Passing the cell reference to a variable Artist Excel VBA 0 April 14th, 2004 04:34 AM
Passing a class by reference James Diamond VB How-To 13 February 16th, 2004 06:07 AM
Passing Reference Types by Value semiloof VS.NET 2002/2003 1 December 22nd, 2003 12:16 AM
Passing by reference jacob ASP.NET 1.0 and 1.1 Basics 1 July 12th, 2003 05:07 PM





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