DCOM server
-
I am trying to write a DCOM server application. Some of the interface functions have paramaters that are user defined data types (structs). I have the header files where these type definitions are included in the server .h file included in the .h file of the server .cpp file. When I try to build, I receive the following error that points back to the .idl file: "Expecting type specification near "data_type". Any advice on how to remedy this. I am fairly new to DCOM/COM programming.
-
I am trying to write a DCOM server application. Some of the interface functions have paramaters that are user defined data types (structs). I have the header files where these type definitions are included in the server .h file included in the .h file of the server .cpp file. When I try to build, I receive the following error that points back to the .idl file: "Expecting type specification near "data_type". Any advice on how to remedy this. I am fairly new to DCOM/COM programming.
Hi, (1) Your interfaces which uses structs or other defined types must me custom defined. (2) The only place where you must define your structs is the .idl file (see below). (3) Don't forget to compile your PS.mk (Visual Studio generatied make file) (4) Use CoTaskMemAlloc() and CoTaskMemFree() to transfer the struct data (example shows an array of structs) Success Aat EXAMPLE // YourServer.idl : IDL source for YourServer.dll // // This file will be processed by the MIDL tool to // produce the type library (YourServer.tlb) and marshalling code. import "oaidl.idl"; import "ocidl.idl"; typedef struct { int iType; int iValue; // E.t.c. } YOURSTRUCT; // .... [ object, uuid(BECF60B9-2741-11D4-A05E-00B0D0201DD6), helpstring("IYourObject Interface"), pointer_default(unique) ] interface IYourObject : IUnknown { [helpstring("method Read")] HRESULT Read([out,size_is(,*plNumStructs)] YOURSTRUCT** ppYourStructs, [in, out] long* plNumStructs); [helpstring("method Write")] HRESULT Write([in,size_is(lNumStructs)] YOURSTRUCT* pYourStructs, [in] long lNumStructs); };