Marshaling OLE Data Types
To make it easier to use certain Automation data types and COM handles in remote operations, wire_marshal typedefs for these data types, and their related helper functions, are available by importing Win32 IDL files and linking to the OLE and AUTOMATION DLL files. These files are automatically installed on your system during installation of Microsoft® Windows NT® or Windows® 95.
-
To use the BSTR data type in remote procedure calls, import the wtypes.idl file into your interface definition (IDL) file and link to oleaut32.lib when building your distributed application. This will let your stubs use the ready-made helper functions BSTR_UserSize, BSTR_UserMarshal, BSTR_UserUnmarshal, and BSTR_UserFree.
-
To use other Automation data types, such as VARIANT and SAFEARRAY, or types that use those types (for example, DISPPARAM and EXCEPINFO), import the objidl.idl file into your IDL file and link to the oleaut32.lib at build time. This will allow you to use the appropriate helper routines.
-
To use OLE data types and handles (such as CLIPFORMAT, SNB, STGMEDIUM, ASYNC_STGMEDIUM, HMETAFILE_PICT, HENHMETAFILE, HMETAFILE, HBITMAP, HPALETTE, and HGLOBAL), import the objidl.idl file into your interface definition file and link to the ole32.lib at build time.
-
The following OLE handles are also defined with the wire_marshal attribute, but only as handles within a machine since they cannot be used in remote procedure calls to other machines at this time: HWND, HMENU, HACCEL, HDC, HFONT, HICON, HBRUSH. Import the objidl.idl file into your IDL file and link to ole32.lib at build time to use these handles in interprocess communication on a single machine. The helper routines for these data types may change to include support for remote marshaling in a future release.
Note The technology needed to support the above-described data types in proxy/stub code is part of Windows NT 4.0 only; this support is not present in Windows NT 3.51, Windows 95, or earlier versions of Windows. Therefore any application you develop on Windows NT 4.0, that uses these data types in remote procedure calls, will not run on an earlier platform. (The upcoming DCOM release for Windows 95 will include this support.) If your application needs to run on older platforms, and it uses these data types in remote procedure calls, you will need to create your own marshaling routines, using the transmit_as or represent_as attributes and their related helper functions. This restriction does not apply to type libraries generated with MIDL 3.0 for Automation/dual interfaces.
See Also
The wire_marshal Attribute, The type_UserSize Function, The type_UserMarshal Function, The type_UserUnmarshal Function, The type_UserFree Function, The transmit_as Attribute, The represent_as Attribute, Targetting Stubs for Specific 32-Bit Platforms