Click here to Skip to main content
15,902,445 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: dual interface Pin
George_George12-Sep-08 19:48
George_George12-Sep-08 19:48 
GeneralRe: dual interface Pin
Scott Holt12-Sep-08 14:38
Scott Holt12-Sep-08 14:38 
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 
1) Well, not necessarily: for example, automation directly supports BSTR (b-strings) and 4-byte integer values (known as long integers in C++), BUT...to keep things more simple, I would recommend just using VARIANT for all of your parameters, as you suggest. If you study the VARIANT data type closely, you'll see that the VARIANT structure itself actually can hold many other data types. Its up to you to figure out what a VARIANT contains by looking at the '.vt' member of the structure.

Also, if you're writing in VB, VB can automatically convert from VARIANT to other data types for you. I believe C# can do this also, although I haven't really dabbled in C# yet. If you're writing in C++, you can use the _variant_t class which provides many conversion operators (I use _variant_t all the time in my C++ code).

2) I wouldn't necessarily recommend using a custom data type through the IDispatch interface unless your ready to write "custom marshalling" routines. "Marshaling" is the process of packaging up your function calls and parameters, then passing them across process boundaries, and possibly even across machine boundaries if you are going to have a client on one machine invoke a COM server on another machine (which is another really cool thing to do with COM). Microsoft provides COM components that can performing the marshalling for you based on the information you have in your IDL.

Is there a way you can take your custom data type and make it "look" like a standard type? For example, could your custom data type be type cast as a long integer (vt = VT_I4) and placed into a VARIANT for the function call? And then when the server gets the parameter value, it can type cast it again into whatever you need it to be?

Scott
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 
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 

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.