home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Runimage / Delphi50 / Source / Toolsapi / VIRTINTF.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1999-08-11  |  1.6 KB  |  79 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Borland Delphi Visual Component Library         }
  5. {                                                       }
  6. {       Copyright (c) 1995,99 Inprise Corporation       }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit VirtIntf;
  11.  
  12. interface
  13.  
  14. type
  15.   TInterface = class
  16.   private
  17.     FRefCount: Longint;
  18.   public
  19.     constructor Create;
  20.     procedure Free;
  21.     function AddRef: Longint; virtual; stdcall;
  22.     function Release: Longint; virtual; stdcall;
  23.     function GetVersion: Integer; virtual; stdcall;
  24.   end;
  25.  
  26.   { IStreamModifyTime - Allows setting the file time stamp of an IStream }
  27.  
  28.   IStreamModifyTime = interface
  29.     ['{12452621-5F8A-11D1-9FB6-0020AF3D82DA}']
  30.     function GetModifyTime: Longint; stdcall;
  31.     procedure SetModifyTime(Time: Longint); stdcall;
  32.   end;
  33.  
  34. function ReleaseException: string;
  35.  
  36. implementation
  37.  
  38. uses SysUtils;
  39.  
  40. { TInterface }
  41.  
  42. constructor TInterface.Create;
  43. begin
  44.   inherited Create;
  45.   FRefCount := 1;
  46. end;
  47.  
  48. procedure TInterface.Free;
  49. begin
  50.   if Self <> nil then Release;
  51. end;
  52.  
  53. function TInterface.AddRef: Longint;
  54. begin
  55.   Inc(FRefCount);
  56.   Result := FRefCount;
  57. end;
  58.  
  59. function TInterface.Release: Longint;
  60. begin
  61.   Dec(FRefCount);
  62.   Result := FRefCount;
  63.   if FRefCount = 0 then Destroy;
  64. end;
  65.  
  66. function TInterface.GetVersion: Integer;
  67. begin
  68.   Result := 3;
  69. end;
  70.  
  71. { Exception handling }
  72.  
  73. function ReleaseException: string;
  74. begin
  75.   Result := Exception(ExceptObject).Message;
  76. end;
  77.  
  78. end.
  79.