Click here to Skip to main content
15,891,700 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: dual interface Pin
George_George12-Sep-08 19:58
George_George12-Sep-08 19:58 
GeneralRe: dual interface Pin
Scott Holt13-Sep-08 1:25
Scott Holt13-Sep-08 1:25 
GeneralRe: dual interface Pin
George_George14-Sep-08 0:16
George_George14-Sep-08 0:16 
GeneralRe: dual interface Pin
Scott Holt16-Sep-08 9:24
Scott Holt16-Sep-08 9:24 
GeneralRe: dual interface Pin
George_George16-Sep-08 19:56
George_George16-Sep-08 19:56 
GeneralRe: dual interface Pin
Scott Holt18-Sep-08 2:24
Scott Holt18-Sep-08 2:24 
GeneralRe: dual interface Pin
George_George18-Sep-08 21:27
George_George18-Sep-08 21:27 
GeneralRe: dual interface Pin
Scott Holt22-Sep-08 2:25
Scott Holt22-Sep-08 2:25 
Yes, the VARIANT data type IS "automation-compatible". In fact, the last time I checked, all parameters to the IDispatch interface HAD to be VARIANT. Thus, your phrase "means if a data type could be represented by VARIANT, it is automation compatible" is TRUE.

I am not sure where you found something that indicates that a VARIANT is not an ole automation data type, but I think what you found is in error.

There are other data types that can be marshalled between a COM client and a COM server, but you must use VARIANT with the IDispatch interface.

Now, in the early days, "automation" was referred to as "OLE automation", where the acronym "OLE" meant "Object Linking and Embedding". This was a phrase that Microsoft used to describe its early techonologies for allowing their Office applications to work with each other. "OLE automation" was the precursor to COM. Later on, the VB team at Microsoft created the IDispatch interface, "OLE automation" bcame the foundation for "ActiveX" controls, people dropped the acronym "OLE" and simply started referring to "OLE automation" as just "automation", and the VB folks defined "automation" as meaning "a COM component that supports the IDispatch interface".

These days, however, "automation" is generally accepted to mean simply "a software component that adheres to the COM specification", even if it does not support IDispatch. (Remember, a COM component does not have to support IDispatch.)

Now, if you have ever programmed in VB, you know that you can use a variable without first declaring it. When you do this, VB automatically creates a variable of type...VARIANT. From the outset, VB is designed to be very flexible with regard to its data types, and because VB was both a compiled language AND a scripted language, the VARIANT data type was very convenient for passing data between software components that were bound at run-time (as with VB script).

So, you can see why VARIANT is so important to the IDispatch interface. The VB folks at Microsoft had a strong influence on COM and the IDispatch interface. They were also very interested in the use of ActiveX controls (COM components) in VB form applications, and web-based applications using VB script.

So, the moral of the story is: VARIANT is an "automation-compatible" data type, and is in fact probably the most commonly used data type for passing data between COM components.

Now, there are other "automation" data types, for example BSTR. You can pass a BSTR between a COM client and a COM server. The "marshalling" code produced by the MIDL compliler handles BSTR values quite nicely. So, VARIANT is not the only "automation" data type, but you could easily use VARIANT for ALL of your parameters if you wanted to.

This is what I do: All parameters passed between my COM clients and my COM servers are either VARIANTs, BSTRs, or long integers (four-byte integer values). Once I get the data inside my COM client or my COM server, I will typecast or convert the data into whatever type or structure I need to maniuplate the data "inside" the client or server code. If/when I need to send the data back to the client/server, I simply convert back to VARIANT, BSTR, or long integer.

Scott
Smile | :)
GeneralRe: dual interface Pin
George_George22-Sep-08 19:40
George_George22-Sep-08 19:40 
GeneralRe: dual interface Pin
Scott Holt24-Sep-08 0:40
Scott Holt24-Sep-08 0:40 
GeneralRe: dual interface Pin
George_George24-Sep-08 0:46
George_George24-Sep-08 0:46 
GeneralRe: dual interface Pin
Scott Holt25-Sep-08 0:13
Scott Holt25-Sep-08 0:13 
GeneralRe: dual interface Pin
George_George27-Sep-08 0:16
George_George27-Sep-08 0:16 
GeneralRe: dual interface Pin
George_George11-Sep-08 23:50
George_George11-Sep-08 23:50 
GeneralRe: dual interface Pin
CPallini12-Sep-08 0:56
mveCPallini12-Sep-08 0:56 
GeneralRe: dual interface Pin
George_George12-Sep-08 19:49
George_George12-Sep-08 19:49 
GeneralRe: dual interface Pin
George_George12-Sep-08 19:58
George_George12-Sep-08 19:58 
GeneralRe: dual interface Pin
CPallini12-Sep-08 21:44
mveCPallini12-Sep-08 21:44 
GeneralRe: dual interface Pin
George_George14-Sep-08 0:10
George_George14-Sep-08 0:10 
GeneralRe: dual interface Pin
CPallini12-Sep-08 21:53
mveCPallini12-Sep-08 21:53 
GeneralRe: dual interface Pin
George_George14-Sep-08 0:12
George_George14-Sep-08 0:12 
GeneralRe: dual interface Pin
CPallini14-Sep-08 0:34
mveCPallini14-Sep-08 0:34 
GeneralRe: dual interface Pin
George_George14-Sep-08 2:00
George_George14-Sep-08 2:00 
GeneralRe: dual interface Pin
CPallini14-Sep-08 2:27
mveCPallini14-Sep-08 2:27 
GeneralRe: dual interface Pin
George_George14-Sep-08 2:41
George_George14-Sep-08 2:41 

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.