Figure 2   Implementing Out-of-Process Objects

Interface Marshaling Need IDL to Generate Proxy/Stub? MFC Wizard Generated ATL Wizard Generated Need IDL or ODL
for Type Library?
MFC Wizard Generated ATL Wizard Generated
Custom Custom No. You're writing your own proxy/stub. N/A N/A No N/A N/A
Custom Standard Yes. No Yes No N/A N/A
Standard IDispatch No. Will use Universal Marshaler. N/A N/A Yes Yes No
Standard Non-IDispatch No. A standard proxy/stub already exists. N/A N/A No N/A N/A
Dual Standard and IDispatch No. Will use Universal Marshaler. No Yes Yes No Yes


Figure 3   Standard IDL Include Files

File Interfaces and Imports
wtypes.idl Typedefs for remotable data types. This file contains all of the typedefs and #defines for everything from Windows to COM. This is one of those "one place contains everything" files like the Old windows.h, but without the function declarations. This is the fundamental definitions file; you won't find any import statements here.
unknwn.idl IUnknown and IClassFactory. Imports wtypes.idl.
objidl.idl Fundamental COM support interfaces. Imports wtypes.idl and unknwn.idl.
  COM interfaces IMarshal, IMalloc, IMallocSpy, IStdMarshalInfo, IExternalConnection, IMultiQI, and IEnumUnknown.
  Binding interfaces IBindCtx, IEnumMoniker, IRunnableObject, IRunningObjectTable,IPersist, IPersistStream, IMoniker, IROTData and IEnumString.
  Structured Storage interfaces ISequentialStream, IStream, IEnumSTATSTG, IStorage, IPersistFile, IPersistStorage, ILockBytes, IFillLockBytes, IEnumFORMATETC, IEnumSTATDATA, IRootStorage and ILayoutStorage.
  Notification interfaces IAdviseSink, IAdviseSink2, IDataObject, IDataAdviseHolder, and IMessageFilter.
  Object Remoting interfaces IRpcChannelBuffer, IRpcProxyBuffer, IRpcStubBuffer, IPSFactoryBuffer, and IChannelHook.
  Property Storage interfaces IPropertyStorage, IPropertySetStorage, IEnumSTATPROPSTG and IEnumSTGATPROPSETSTG.
  Connection Point interfaces IConnectionPoint, IConnectionPointContainer, IEnumConnections, IEnumConnectionPoints.
  Security interfaces IClientSecurity and IServerSecurity.
  Miscellaneous interfaces IClassActivator and IProgressNotify.
oaidl.idl Automation interfaces. Imports objidl.idl. IOLEAutomationTypes, ICreateTypeInfo, ICreateTypeInfo2, ICreateTypeLib, ICreateTypeLib2, IDispatch, IEnumVARIANT, ITypeComp, ITypeInfo, ITypeInfo2, ITypeLib, ITypeLib2, ITypeChangeEvents, IErrorInfo, ICreateErrorInfo, and ISupportErrorInfo.
OLE Component Category interfaces. Imports unknwn.idl.
oleidl.idl Object Linking and Embedding interfaces. Imports objidl.idl.
ocidl.idl ActiveX control interfaces. Imports oleidl.idl and oaidl.idl.
urlmon.idl Async URL Moniker interfaces. Imports objidl.idl, oleidl.idl, servprov.idl.
hlink.idl Hyperlinking interfaces. Imports urlmon.idl.
docobj.idl OLE Document Object interfaces. Imports objidl.idl, oaidl.idl, oleidl.idl, ocidl.idl, and servprov.idl.
 


Figure 5   Viewing IDL in TypeLib Viewer


Figure 6   Visual Basic Auto Quick Info


Figure 10   COM Interface in a Type Library

[uuid(54674299-3A82-101B-8181-00AA003743D3)] library MyLib
{
    [object, uuid(348ACF20-C9B9-11d1-ABE5-966A46661731)]
    interface IDerivedInterface : IUnknown
    {
        import "unknwn.idl";
        import "wtypes.idl";
        HRESULT Fx(int iValue);
    }

    typedef enum {
        btError       = 0x0010,
        btQuestion    = 0x0020,
        btWarning     = 0x0030,
        btInformation = 0x0040
    } BeepTypes;

    [dllname("USER32")]
    module MyUser32
    {
        [entry("MessageBeep"),
            helpstring("Makes the sound specified by btSound")]
        long _stdcall MessageBeep(BeepTypes btSound);
    };
}; 

Figure 11   Fundamental IDL Attributes

Strings and Arrays
Keyword Description
[string] Specifies that this pointer is a null-terminated string.
[size_is] Specifies the number of elements in an array.
[max_is] Specifies the maximum valid index in an array.
[length_is] Specifies the number of elements used in an array.
[first_is] Specifies the index of the first element used in an array.
[last_is] Specifies the index of the last element used in an array.
[in] Specifies that a parameter is only to be marshaled from the client to the server.
[out] Specifies that a parameter is only to be marshaled from the server back to the client.
Help Information
Keyword Description
[helpfile] A help file containing a help topic about the block.
[helpcontext] The context number of the help topic.
[helpstring] A one-line description for an item that appears in object browsers that view the type library.
Pointers
Keyword Description
[ref] Signifies a reference pointer (cannot be null).
[unique] Signifies a unique pointer (can be null).
[ptr] Signifies a full pointer (checks for duplicates).
Interfaces
Keyword Description
[uuid] A universally unique identifier. Synonymous with a GUID, and required for libraries, interfaces, and coclasses.
library Creates a type library.
module Specifies a module (DLL).
interface Specifies an RPC interface, unless the [object] attribute is present, in which case it is a COM interface.
[object] Specifies that the interface is to be a COM interface.
[dual] Specifies that the interface is to expose a vtable interface and a dispinterface.
dispinterface Specifies an IDispatch logical interface.
coclass Specifies a COM class and all of the interfaces that it implements.
importlib Imports one type library into another. STDOLE.TLB contains all of the standard OLE definitions.
import Acts like an #include, but for IDL files.
[entry] Method entry point for a module.
[propget] Specifies a property-getting function.
[propput] Specifies a property-setting function.
Miscellaneous
Keyword Description
[local] Suppresses the generation of networking code for this method.
cpp_quote Places text directly into the header file generated for the proxy/stub.
[source] Specifies an event source.