The information in this article applies to:
SUMMARY
Standard marshaling code for custom COM interfaces, generated by using
the MIDL compiler or written manually, doesn't support 16-bit to 16-bit or
16-bit to 32-bit interoperability in Windows 95 and in Windows NT version
3.51. MORE INFORMATION
A COM interface can be marshaled using standard marshaling or custom
marshaling. In standard marshaling, proxy and stub code marshals and
unmarshals the parameters and return values of an interface method call
between processes. In custom marshaling, the object implements IMarshal to
marshal the entire object to another process space. Using Custom MarshalingYou can use custom marshaling to marshal the server object that implements the custom interface. Custom marshaling also requires that the server implement IMarshal. OLE will use IMarshal::MarshalInterface to marshal the custom interface and will use IMarshal::GetUnMarshalClass to obtain the CLSID of the unmarshaller object. The unmarshaller must be registered in the system registry. A 16-bit and a 32-bit implementation of the unmarshaler object must be provided if you are interested in 16-bit to 32- bit interoperability. The InprocServer entry under the CLSID of the unmarshaler object in the registry should point to the 16-bit implementation and the InprocServer32 entry should point to the 32-bit implementation. OLE will create an instance of the unmarshaler object in the process space of the client and will use its IMarshal::UnMarshalInterface to unmarshal the entire object in the client's process space. Consequently custom marshaling is appropriate for objects whose state doesn't change or whose state is kept in shared memory. It may not be appropriate for all objects.Using OLE Automation's MarshalerYou can use standard marshaling as implemented by OLE automation's marshaler. The OLE automation marshaler provides 16-bit and 32-bit standard marshaling code that can run under Windows 95 and Windows NT 3.51. It is generic enough to marshal any custom interface that is described using a type library and that uses a limited set of data types called the OLE Automation compatible types. This will allow 16-bit to 16-bit local server and 16-bit to 32-bit local server interoperability of the custom interface under both Windows 95 and Windows NT 3.51.This marshaler implements OLE Automation's vtbl-binding. Vtbl-binding is the mechanism used by any COM interface client to bind to the implementation of the COM interface in the server. OLE Automation uses this term to distinguish it from the other binding mechanisms it supports, such as late-binding and id-binding. The types that can be used in interfaces that can be marshaled by the OLE Automation marshaler are restricted to the OLE Automation compatible types discussed below. In addition, because the OLE Automation marshaler is generic, it is not as efficient as the marshaling code generated by MIDL. Because of these limitations, you should consider this approach only if you are interested in 16-bit to 16-bit or 16-bit to 32-bit interoperabilty. Otherwise, use the MIDL compiler to generate marshaling code. Important Implementation DetailsFor documentation and a sample tha shows how to create a custom interface that is marshaled by OLE Automation's marshaler, please see the following article in the Microsoft Knowledge Base:Q139074 SAMPLE: VTBLBIND: Marshaling Using an OLE Automation MarshalerThe server describes the custom interface in the Object Description Language (ODL) in Server.odl. Server.odl is compiled by mktyplib to produce the type library Server.tlb and the interface declaration file IVtblSrv.h. For example, the IVtblServer custom interface is described as follows:
The IVtblServer custom interface derives from IUnknown and has three
methods. The uuid attribute specifies the Interface ID of the interface.
The oleautomation attribute specifies that the interface can be marshaled
by the marshaler provided by OLE Automation.The ODL syntax is described in Chapter 7 of OLE Programmer's Reference Volume 2, second edition. Information on how to obtain the second edition of this book can be found in the following article in the Microsoft Knowledge Base: Q124385 SAMPLE: OLE Automation '94 Documentation and SamplesThe types that can be used by the custom interface are restricted to the following OLE Automation compatible types: shortThe marshaler provided by OLE Automation cannot understand structures. Structures can be passed using a SAFEARRAY(unsigned char). For more information about passing structures, please see the following articles in the Microsoft Knowledge Base: Q122289 Passing Structures in OLE Automation Q131046 SAMPLE: BINARY: Transfer Binary Data Using OLE Automation Custom Interface ImplementationThe custom interface is implemented in the server, and the custom interface and type library are registered.The custom interface, IVtblServer, is registered as follows:
{2ED17402-F80F-11ce-8161-00AA0060D733} corresponds to the Interface ID
of the custom interface. {00020424-0000-0000-C000-000000000046} is the
CLSID of the OLE Automation marshaler that will marshal this custom
interface. This is a CLSID that is provided by OLE. The TypeLib key
is used to point to the GUID of the type library that describes this
custom interface. When the custom interface is marshaled, OLE will look
up its interface registration in the system registry using the Interface
ID.The ProxyStubClsid(32) key will point to the object that will marshal the interface. OLE will create this object and ask it to marshal the interface. In this case, OLE will create the OLE Automation marshaler. The OLE Automation marshaler will use the TypeLib key to obtain the type library, which describes the interface and will marshal the interface based on this type information. The CLSID specified by ProxyStubClsid(32) must always be {00020424-0000-0000-C000-000000000046} for an interface that is to be marshaled by the OLE Automation marshaler. The type library is registered as follows:
{2ED17400-F80F-11ce-8161-00AA0060D733} is the GUID of the type library.
\1.0\0\win32 corresponds to version 1.0 and locale ID 0 (language neutral)
of the type library on the win32 platform. The version and locale ID
correspond to the version and lcid attributes in Server.odl. The locale ID
is important for late-binding in OLE automation and is not important for
vtbl-binding. The full path of Server.tlb is registered.
Additional query words: 4.00
Keywords : kbAutomation kbCOMt kbNTOS351 kbNTOS400 kbWinOS95 kbGrpCom kbDSupport LeTwoArc |
Last Reviewed: October 26, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |