这是COM库单元
library TIServer;uses
  ComServ,
  DCPTypeServer_TLB in 'DCPTypeServer_TLB.pas',
  AreaIntf in 'AreaIntf.pas' {UnitAuto: CoClass};exports
  DllGetClassObject,
  DllCanUnloadNow,
  DllRegisterServer,
  DllUnregisterServer;{$R *.TLB}{$R *.RES}begin
end.这是COM接口单元
unit DCPTypeServer_TLB;{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers. 
{$WARN SYMBOL_PLATFORM OFF}
{$WRITEABLECONST ON}
{$VARPROPSETTER ON}
interfaceuses Windows, ActiveX, Classes, Graphics, StdVCL, Variants;
  
const
  // TypeLibrary Major and minor versions
  DCPTypeServerMajorVersion = 1;
  DCPTypeServerMinorVersion = 0;  LIBID_DCPTypeServer: TGUID = '{91ADB6E6-4F4D-11D3-B84B-0040F67455FE}';  IID_IUnitAuto: TGUID = '{91ADB6E7-4F4D-11D3-B84B-0040F67455FE}';
  CLASS_UnitAuto: TGUID = '{91ADB6E9-4F4D-11D3-B84B-0040F67455FE}';// *********************************************************************//
// Declaration of Enumerations defined in Type Library                    
// *********************************************************************//
// Constants for enum AreaUnit
type
  AreaUnit = TOleEnum;
const
  auSquareMeters = $00000000;
  auSquareCentimeters = $00000001;
  auSquareYards = $00000002;
  auSquareFeet = $00000003;
  auSquareInches = $00000004;
  auSquareKilometers = $00000005;
  auSquareMiles = $00000006;
  auAcres = $00000007;type// *********************************************************************//
// Forward declaration of types defined in TypeLibrary                    
// *********************************************************************//
  IUnitAuto = interface;// *********************************************************************//
// Declaration of CoClasses defined in Type Library                       
// (NOTE: Here we map each CoClass to its Default Interface)              
// *********************************************************************//
  UnitAuto = IUnitAuto;
// *********************************************************************//
// Interface: IUnitAuto
// Flags:     (256) OleAutomation
// GUID:      {91ADB6E7-4F4D-11D3-B84B-0040F67455FE}
// *********************************************************************//
  IUnitAuto = interface(IUnknown)
    ['{91ADB6E7-4F4D-11D3-B84B-0040F67455FE}']
    function Convert(Quantity: Double; InUnit: SYSINT; OutUnit: SYSINT): Double; stdcall;
  end;// *********************************************************************//
// The Class CoUnitAuto provides a Create and CreateRemote method to          
// create instances of the default interface IUnitAuto exposed by              
// the CoClass UnitAuto. The functions are intended to be used by             
// clients wishing to automate the CoClass objects exposed by the         
// server of this typelibrary.                                            
// *********************************************************************//
  CoUnitAuto = class
    class function Create: IUnitAuto;
    class function CreateRemote(const MachineName: string): IUnitAuto;
  end;implementationuses ComObj;class function CoUnitAuto.Create: IUnitAuto;
begin
  Result := CreateComObject(CLASS_UnitAuto) as IUnitAuto;
end;class function CoUnitAuto.CreateRemote(const MachineName: string): IUnitAuto;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_UnitAuto) as IUnitAuto;
end;end.这是COM实现单元
unit AreaIntf;interfaceuses
  Windows, ActiveX, Classes, ComObj, DCPTypeServer_TLB, StdVcl;type
  TUnitAuto = class(TTypedComObject, IUnitAuto)
  protected
    function Convert(Quantity: Double; InUnit, OutUnit: SYSINT): Double;
      stdcall;
    {Declare IUnitAuto methods here}
  end;implementationuses ComServ;function TUnitAuto.Convert(Quantity: Double; InUnit,
  OutUnit: SYSINT): Double;
const
  AreaFactor:array[auSquareMeters..auAcres]of double=
    (1,2,3,4,5,6,7,8);
begin
  result:=Quantity*AreaFactor[InUnit]/AreaFactor[OutUnit];
  { Stubbed out because we're only interested in the type library }
end;initialization
  TTypedComObjectFactory.Create(ComServer, TUnitAuto, Class_UnitAuto,
    ciMultiInstance, tmApartment);
end.下面是调用
procedure TForm1.Button1Click(Sender: TObject);
var
  V:variant;
begin
  V:=CreateOleObject('DCPTypeServer.UnitAuto');//<---执行到这里时就提示“不支持此接口”
  showmessage(floattostr(V.convert(1.0,0,1)));
end;