Click here to Skip to main content
16,016,157 members
Home / Discussions / COM
   

COM

 
GeneralRe: retrun BSTR Pin
Michael Dunn24-Sep-01 14:55
sitebuilderMichael Dunn24-Sep-01 14:55 
GeneralCOMAddin for Word2000 and Excel2000 Pin
Sree Ram21-Sep-01 8:55
Sree Ram21-Sep-01 8:55 
GeneralMFC CFtpFileFind CFtpConnection and timeout Pin
Amit Dey21-Sep-01 6:07
Amit Dey21-Sep-01 6:07 
GeneralRe: MFC CFtpFileFind CFtpConnection and timeout Pin
Carlos Antollini21-Sep-01 6:44
Carlos Antollini21-Sep-01 6:44 
GeneralAdvanced problem -- DCOM remoting in VB without configuration of DCOMCNFG Pin
21-Sep-01 4:50
suss21-Sep-01 4:50 
GeneralTo pass a structure/class object across com components Pin
20-Sep-01 23:48
suss20-Sep-01 23:48 
GeneralRe: To pass a structure/class object across com components Pin
Not Active21-Sep-01 2:33
mentorNot Active21-Sep-01 2:33 
GeneralRe: To pass a structure/class object across com components Pin
Aaron Schaefer21-Sep-01 4:01
Aaron Schaefer21-Sep-01 4:01 
Hi Shesh,

If the variables fits logically into a structure, you can create a COM object/interface to encapsulate the contents of this structure. Then just pass the disp interface of the structure across. This is the most generic way to do this, and will allow all types of clients (including scripting cilents) access to the contents of the struct. When you get the disp interface on the other side, just QI for the specific interface. Add the fields in the struct as read/write properties on the COM object representing the structure. This will still conform to the oleautomation attribute if you are using dual interfaces.

The interface for the object that contains the struct could look something like:

[
object,
uuid(D867979C-B209-41CD-9EA9-2455B98C64F1),
dual,
helpstring("IMyObject Interface"),
pointer_default(unique)
]
interface IMyObject : IDispatch
{
[id(1), helpstring("method GetData")] HRESULT GetData([out, retval] LPDISPATCH* pVal);
};

While the interface for the struct might look like:

[
object,
uuid(979D94E5-A586-452D-855D-0CE997BCC0AC),
dual,
helpstring("IDataStruct Interface"),
pointer_default(unique)
]
interface IDataStruct : IDispatch
{
[propget, id(1), helpstring("property Field1")] HRESULT Field1([out, retval] double *pVal);
[propput, id(1), helpstring("property Field1")] HRESULT Field1([in] double newVal);
[propget, id(2), helpstring("property Field2")] HRESULT Field2([out, retval] double *pVal);
[propput, id(2), helpstring("property Field2")] HRESULT Field2([in] double newVal);
};

In general, you can pass "objects" around in a dispatch friendly way by passing their dispatch interfaces, then dispatch clients will be able to use them. C++ clients can QI for the most specific interface (in this case, IDataStruct).

If you are not exposing dual interfaces on your COM object, you may want to have a look at the MIDL struct declaration. This would only be useful if you are using custom interfaces and did not have to worry about satisfying the oleautomation attribute.

I think there are a lot of other approaches to this as well, but I've had success with this one.
GeneralRe: To pass a structure/class object across com components Pin
ioannhs_s21-Sep-01 5:08
ioannhs_s21-Sep-01 5:08 
GeneralCOMponent dependencies Pin
Brian van der Beek20-Sep-01 22:50
Brian van der Beek20-Sep-01 22:50 
GeneralDISPPARAMS (COM) Pin
20-Sep-01 0:27
suss20-Sep-01 0:27 
Generaladsi:create attribute failed! Pin
19-Sep-01 22:34
suss19-Sep-01 22:34 
Generalpassing char * to COM Object function Pin
Stephane Denis19-Sep-01 17:31
Stephane Denis19-Sep-01 17:31 
GeneralRe: passing char * to COM Object function Pin
Chris Losinger19-Sep-01 17:51
professionalChris Losinger19-Sep-01 17:51 
GeneralRe: passing char * to COM Object function Pin
Stephane Denis20-Sep-01 10:37
Stephane Denis20-Sep-01 10:37 
GeneralRe: passing char * to COM Object function Pin
Chris Losinger20-Sep-01 10:50
professionalChris Losinger20-Sep-01 10:50 
GeneralRe: passing char * to COM Object function Pin
Michael P Butler20-Sep-01 10:51
Michael P Butler20-Sep-01 10:51 
GeneralRe: passing char * to COM Object function Pin
Stephane Denis20-Sep-01 11:45
Stephane Denis20-Sep-01 11:45 
GeneralUser defined structure cannot be exported as a property Pin
19-Sep-01 7:52
suss19-Sep-01 7:52 
GeneralRe: User defined structure cannot be exported as a property Pin
ioannhs_s21-Sep-01 5:08
ioannhs_s21-Sep-01 5:08 
GeneralCOM Addins (A request for guidence and ideas) Pin
Michael P Butler18-Sep-01 23:34
Michael P Butler18-Sep-01 23:34 
GeneralRe: COM Addins (A request for guidence and ideas) Pin
Michael P Butler19-Sep-01 0:51
Michael P Butler19-Sep-01 0:51 
GeneralRe: COM Addins (A request for guidence and ideas) Pin
Anonymous27-Aug-02 9:06
Anonymous27-Aug-02 9:06 
QuestionProblem: VC client and COM+ Server Component, but VB client works just fine. Why? Pin
17-Sep-01 9:05
suss17-Sep-01 9:05 
AnswerRe: Problem: VC client and COM+ Server Component, but VB client works just fine. Why? Pin
Carlos Antollini17-Sep-01 9:25
Carlos Antollini17-Sep-01 9:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.