home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Delphi.5 / Samples / sourceD5 / browutil.exe / BROWSER / BROWSE~1.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-01-02  |  8.7 KB  |  251 lines

  1. unit Browser_TLB;
  2.  
  3. // ************************************************************************ //
  4. // WARNING                                                                    
  5. // -------                                                                    
  6. // The types declared in this file were generated from data read from a       
  7. // Type Library. If this type library is explicitly or indirectly (via        
  8. // another type library referring to this type library) re-imported, or the   
  9. // 'Refresh' command of the Type Library Editor activated while editing the   
  10. // Type Library, the contents of this file will be regenerated and all        
  11. // manual modifications will be lost.                                         
  12. // ************************************************************************ //
  13.  
  14. // PASTLWTR : $Revision:   1.88  $
  15. // File generated on 1/2/00 6:20:35 PM from Type Library described below.
  16.  
  17. // *************************************************************************//
  18. // NOTE:                                                                      
  19. // Items guarded by $IFDEF_LIVE_SERVER_AT_DESIGN_TIME are used by properties  
  20. // which return objects that may need to be explicitly created via a function 
  21. // call prior to any access via the property. These items have been disabled  
  22. // in order to prevent accidental use from within the object inspector. You   
  23. // may enable them by defining LIVE_SERVER_AT_DESIGN_TIME or by selectively   
  24. // removing them from the $IFDEF blocks. However, such items must still be    
  25. // programmatically created via a method of the appropriate CoClass before    
  26. // they can be used.                                                          
  27. // ************************************************************************ //
  28. // Type Lib: D:\CODE\DELPHI\BROWSER5\Browser.tlb (1)
  29. // IID\LCID: {70B65734-F8D2-11D2-A0ED-000000000000}\0
  30. // Helpfile: 
  31. // DepndLst: 
  32. //   (1) v2.0 stdole, (C:\WINDOWS\SYSTEM\STDOLE2.TLB)
  33. //   (2) v4.0 StdVCL, (C:\WINDOWS\SYSTEM\STDVCL40.DLL)
  34. // ************************************************************************ //
  35. {$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers. 
  36. interface
  37.  
  38. uses Windows, ActiveX, Classes, Graphics, OleServer, OleCtrls, StdVCL;
  39.  
  40. // *********************************************************************//
  41. // GUIDS declared in the TypeLibrary. Following prefixes are used:        
  42. //   Type Libraries     : LIBID_xxxx                                      
  43. //   CoClasses          : CLASS_xxxx                                      
  44. //   DISPInterfaces     : DIID_xxxx                                       
  45. //   Non-DISP interfaces: IID_xxxx                                        
  46. // *********************************************************************//
  47. const
  48.   // TypeLibrary Major and minor versions
  49.   BrowserMajorVersion = 1;
  50.   BrowserMinorVersion = 0;
  51.  
  52.   LIBID_Browser: TGUID = '{70B65734-F8D2-11D2-A0ED-000000000000}';
  53.  
  54.   IID_ICOMBrowser: TGUID = '{70B65735-F8D2-11D2-A0ED-000000000000}';
  55.   CLASS_COMBrowser: TGUID = '{70B65737-F8D2-11D2-A0ED-000000000000}';
  56. type
  57.  
  58. // *********************************************************************//
  59. // Forward declaration of types defined in TypeLibrary                    
  60. // *********************************************************************//
  61.   ICOMBrowser = interface;
  62.  
  63. // *********************************************************************//
  64. // Declaration of CoClasses defined in Type Library                       
  65. // (NOTE: Here we map each CoClass to its Default Interface)              
  66. // *********************************************************************//
  67.   COMBrowser = ICOMBrowser;
  68.  
  69.  
  70. // *********************************************************************//
  71. // Interface: ICOMBrowser
  72. // Flags:     (0)
  73. // GUID:      {70B65735-F8D2-11D2-A0ED-000000000000}
  74. // *********************************************************************//
  75.   ICOMBrowser = interface(IUnknown)
  76.     ['{70B65735-F8D2-11D2-A0ED-000000000000}']
  77.   end;
  78.  
  79. // *********************************************************************//
  80. // The Class CoCOMBrowser provides a Create and CreateRemote method to          
  81. // create instances of the default interface ICOMBrowser exposed by              
  82. // the CoClass COMBrowser. The functions are intended to be used by             
  83. // clients wishing to automate the CoClass objects exposed by the         
  84. // server of this typelibrary.                                            
  85. // *********************************************************************//
  86.   CoCOMBrowser = class
  87.     class function Create: ICOMBrowser;
  88.     class function CreateRemote(const MachineName: string): ICOMBrowser;
  89.   end;
  90.  
  91.  
  92. // *********************************************************************//
  93. // OLE Server Proxy class declaration
  94. // Server Object    : TCOMBrowser
  95. // Help String      : COMBrowser Object
  96. // Default Interface: ICOMBrowser
  97. // Def. Intf. DISP? : No
  98. // Event   Interface: 
  99. // TypeFlags        : (2) CanCreate
  100. // *********************************************************************//
  101. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  102.   TCOMBrowserProperties= class;
  103. {$ENDIF}
  104.   TCOMBrowser = class(TOleServer)
  105.   private
  106.     FIntf:        ICOMBrowser;
  107. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  108.     FProps:       TCOMBrowserProperties;
  109.     function      GetServerProperties: TCOMBrowserProperties;
  110. {$ENDIF}
  111.     function      GetDefaultInterface: ICOMBrowser;
  112.   protected
  113.     procedure InitServerData; override;
  114.   public
  115.     constructor Create(AOwner: TComponent); override;
  116.     destructor  Destroy; override;
  117.     procedure Connect; override;
  118.     procedure ConnectTo(svrIntf: ICOMBrowser);
  119.     procedure Disconnect; override;
  120.     property  DefaultInterface: ICOMBrowser read GetDefaultInterface;
  121.   published
  122. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  123.     property Server: TCOMBrowserProperties read GetServerProperties;
  124. {$ENDIF}
  125.   end;
  126.  
  127. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  128. // *********************************************************************//
  129. // OLE Server Properties Proxy Class
  130. // Server Object    : TCOMBrowser
  131. // (This object is used by the IDE's Property Inspector to allow editing
  132. //  of the properties of this server)
  133. // *********************************************************************//
  134.  TCOMBrowserProperties = class(TPersistent)
  135.   private
  136.     FServer:    TCOMBrowser;
  137.     function    GetDefaultInterface: ICOMBrowser;
  138.     constructor Create(AServer: TCOMBrowser);
  139.   protected
  140.   public
  141.     property DefaultInterface: ICOMBrowser read GetDefaultInterface;
  142.   published
  143.   end;
  144. {$ENDIF}
  145.  
  146.  
  147. procedure Register;
  148.  
  149. implementation
  150.  
  151. uses ComObj;
  152.  
  153. class function CoCOMBrowser.Create: ICOMBrowser;
  154. begin
  155.   Result := CreateComObject(CLASS_COMBrowser) as ICOMBrowser;
  156. end;
  157.  
  158. class function CoCOMBrowser.CreateRemote(const MachineName: string): ICOMBrowser;
  159. begin
  160.   Result := CreateRemoteComObject(MachineName, CLASS_COMBrowser) as ICOMBrowser;
  161. end;
  162.  
  163. procedure TCOMBrowser.InitServerData;
  164. const
  165.   CServerData: TServerData = (
  166.     ClassID:   '{70B65737-F8D2-11D2-A0ED-000000000000}';
  167.     IntfIID:   '{70B65735-F8D2-11D2-A0ED-000000000000}';
  168.     EventIID:  '';
  169.     LicenseKey: nil;
  170.     Version: 500);
  171. begin
  172.   ServerData := @CServerData;
  173. end;
  174.  
  175. procedure TCOMBrowser.Connect;
  176. var
  177.   punk: IUnknown;
  178. begin
  179.   if FIntf = nil then
  180.   begin
  181.     punk := GetServer;
  182.     Fintf:= punk as ICOMBrowser;
  183.   end;
  184. end;
  185.  
  186. procedure TCOMBrowser.ConnectTo(svrIntf: ICOMBrowser);
  187. begin
  188.   Disconnect;
  189.   FIntf := svrIntf;
  190. end;
  191.  
  192. procedure TCOMBrowser.DisConnect;
  193. begin
  194.   if Fintf <> nil then
  195.   begin
  196.     FIntf := nil;
  197.   end;
  198. end;
  199.  
  200. function TCOMBrowser.GetDefaultInterface: ICOMBrowser;
  201. begin
  202.   if FIntf = nil then
  203.     Connect;
  204.   Assert(FIntf <> nil, 'DefaultInterface is NULL. Component is not connected to Server. You must call ''Connect'' or ''ConnectTo'' before this operation');
  205.   Result := FIntf;
  206. end;
  207.  
  208. constructor TCOMBrowser.Create(AOwner: TComponent);
  209. begin
  210.   inherited Create(AOwner);
  211. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  212.   FProps := TCOMBrowserProperties.Create(Self);
  213. {$ENDIF}
  214. end;
  215.  
  216. destructor TCOMBrowser.Destroy;
  217. begin
  218. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  219.   FProps.Free;
  220. {$ENDIF}
  221.   inherited Destroy;
  222. end;
  223.  
  224. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  225. function TCOMBrowser.GetServerProperties: TCOMBrowserProperties;
  226. begin
  227.   Result := FProps;
  228. end;
  229. {$ENDIF}
  230.  
  231. {$IFDEF LIVE_SERVER_AT_DESIGN_TIME}
  232. constructor TCOMBrowserProperties.Create(AServer: TCOMBrowser);
  233. begin
  234.   inherited Create;
  235.   FServer := AServer;
  236. end;
  237.  
  238. function TCOMBrowserProperties.GetDefaultInterface: ICOMBrowser;
  239. begin
  240.   Result := FServer.DefaultInterface;
  241. end;
  242.  
  243. {$ENDIF}
  244.  
  245. procedure Register;
  246. begin
  247.   RegisterComponents('Servers',[TCOMBrowser]);
  248. end;
  249.  
  250. end.
  251.