home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Runimage / Delphi50 / Demos / Midas / Adhoc / SERV_TLB.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-08-11  |  12.6 KB  |  299 lines

  1. unit Serv_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.62  $
  15. // File generated on 4/22/99 7:17:33 AM from Type Library described below.
  16.  
  17. // ************************************************************************ //
  18. // Type Lib: D:\Temp\demos\MIDAS\ADHOC\server.tlb (1)
  19. // IID\LCID: {85C677A0-F92F-11D0-9FFC-00A0248E4B9A}\0
  20. // Helpfile: 
  21. // DepndLst: 
  22. //   (1) v1.0 Midas, (D:\tp5\bin\midas.dll)
  23. //   (2) v4.0 StdVCL, (D:\TP\bin\stdvcl40.dll)
  24. //   (3) v2.0 stdole, (C:\WINNTS\system32\stdole2.tlb)
  25. // ************************************************************************ //
  26. interface
  27.  
  28. uses Windows, ActiveX, Classes, Graphics, OleServer, OleCtrls, StdVCL, 
  29.   MIDAS;
  30.  
  31. // *********************************************************************//
  32. // GUIDS declared in the TypeLibrary. Following prefixes are used:        
  33. //   Type Libraries     : LIBID_xxxx                                      
  34. //   CoClasses          : CLASS_xxxx                                      
  35. //   DISPInterfaces     : DIID_xxxx                                       
  36. //   Non-DISP interfaces: IID_xxxx                                        
  37. // *********************************************************************//
  38. const
  39.   LIBID_Serv: TGUID = '{85C677A0-F92F-11D0-9FFC-00A0248E4B9A}';
  40.   IID_IAdHocQueryDemo: TGUID = '{85C677A1-F92F-11D0-9FFC-00A0248E4B9A}';
  41.   CLASS_AdHocQueryDemo: TGUID = '{85C677A2-F92F-11D0-9FFC-00A0248E4B9A}';
  42. type
  43.  
  44. // *********************************************************************//
  45. // Forward declaration of types defined in TypeLibrary                    
  46. // *********************************************************************//
  47.   IAdHocQueryDemo = interface;
  48.   IAdHocQueryDemoDisp = dispinterface;
  49.  
  50. // *********************************************************************//
  51. // Declaration of CoClasses defined in Type Library                       
  52. // (NOTE: Here we map each CoClass to its Default Interface)              
  53. // *********************************************************************//
  54.   AdHocQueryDemo = IAdHocQueryDemo;
  55.  
  56.  
  57. // *********************************************************************//
  58. // Interface: IAdHocQueryDemo
  59. // Flags:     (4432) Hidden Dual OleAutomation Dispatchable
  60. // GUID:      {85C677A1-F92F-11D0-9FFC-00A0248E4B9A}
  61. // *********************************************************************//
  62.   IAdHocQueryDemo = interface(IAppServer)
  63.     ['{85C677A1-F92F-11D0-9FFC-00A0248E4B9A}']
  64.     function  GetDatabaseNames: OleVariant; safecall;
  65.     procedure SetDatabaseName(const DBName: WideString; const Password: WideString); safecall;
  66.   end;
  67.  
  68. // *********************************************************************//
  69. // DispIntf:  IAdHocQueryDemoDisp
  70. // Flags:     (4432) Hidden Dual OleAutomation Dispatchable
  71. // GUID:      {85C677A1-F92F-11D0-9FFC-00A0248E4B9A}
  72. // *********************************************************************//
  73.   IAdHocQueryDemoDisp = dispinterface
  74.     ['{85C677A1-F92F-11D0-9FFC-00A0248E4B9A}']
  75.     function  GetDatabaseNames: OleVariant; dispid 2;
  76.     procedure SetDatabaseName(const DBName: WideString; const Password: WideString); dispid 3;
  77.     function  AS_ApplyUpdates(const ProviderName: WideString; Delta: OleVariant; 
  78.                               MaxErrors: Integer; out ErrorCount: Integer; var OwnerData: OleVariant): OleVariant; dispid 20000000;
  79.     function  AS_GetRecords(const ProviderName: WideString; Count: Integer; out RecsOut: Integer; 
  80.                             Options: Integer; const CommandText: WideString; 
  81.                             var Params: OleVariant; var OwnerData: OleVariant): OleVariant; dispid 20000001;
  82.     function  AS_DataRequest(const ProviderName: WideString; Data: OleVariant): OleVariant; dispid 20000002;
  83.     function  AS_GetProviderNames: OleVariant; dispid 20000003;
  84.     function  AS_GetParams(const ProviderName: WideString; var OwnerData: OleVariant): OleVariant; dispid 20000004;
  85.     function  AS_RowRequest(const ProviderName: WideString; Row: OleVariant; RequestType: Integer; 
  86.                             var OwnerData: OleVariant): OleVariant; dispid 20000005;
  87.     procedure AS_Execute(const ProviderName: WideString; const CommandText: WideString; 
  88.                          var Params: OleVariant; var OwnerData: OleVariant); dispid 20000006;
  89.   end;
  90.  
  91. // *********************************************************************//
  92. // The Class CoAdHocQueryDemo provides a Create and CreateRemote method to          
  93. // create instances of the default interface IAdHocQueryDemo exposed by              
  94. // the CoClass AdHocQueryDemo. The functions are intended to be used by             
  95. // clients wishing to automate the CoClass objects exposed by the         
  96. // server of this typelibrary.                                            
  97. // *********************************************************************//
  98.   CoAdHocQueryDemo = class
  99.     class function Create: IAdHocQueryDemo;
  100.     class function CreateRemote(const MachineName: string): IAdHocQueryDemo;
  101.   end;
  102.  
  103.  
  104. // *********************************************************************//
  105. // OLE Server Proxy class declaration
  106. // Server Object    : TAdHocQueryDemo
  107. // Help String      : AdHocQueryDemoObject
  108. // Default Interface: IAdHocQueryDemo
  109. // Def. Intf. DISP? : No
  110. // Event   Interface: 
  111. // TypeFlags        : (2) CanCreate
  112. // *********************************************************************//
  113.   TAdHocQueryDemoProperties= class;
  114.   TAdHocQueryDemo = class(TOleServer)
  115.   private
  116.     FIntf:        IAdHocQueryDemo;
  117.     FProps:       TAdHocQueryDemoProperties;
  118.     function      GetDefaultInterface: IAdHocQueryDemo;
  119.     function      GetServerProperties: TAdHocQueryDemoProperties;
  120.   protected
  121.     procedure InitServerData; override;
  122.   public
  123.     constructor Create(AOwner: TComponent); override;
  124.     destructor  Destroy; override;
  125.     procedure Connect; override;
  126.     procedure Disconnect; override;
  127.     function  AS_ApplyUpdates(const ProviderName: WideString; Delta: OleVariant; 
  128.                               MaxErrors: Integer; out ErrorCount: Integer; var OwnerData: OleVariant): OleVariant;
  129.     function  AS_GetRecords(const ProviderName: WideString; Count: Integer; out RecsOut: Integer; 
  130.                             Options: Integer; const CommandText: WideString; 
  131.                             var Params: OleVariant; var OwnerData: OleVariant): OleVariant;
  132.     function  AS_DataRequest(const ProviderName: WideString; Data: OleVariant): OleVariant;
  133.     function  AS_GetProviderNames: OleVariant;
  134.     function  AS_GetParams(const ProviderName: WideString; var OwnerData: OleVariant): OleVariant;
  135.     function  AS_RowRequest(const ProviderName: WideString; Row: OleVariant; RequestType: Integer; 
  136.                             var OwnerData: OleVariant): OleVariant;
  137.     procedure AS_Execute(const ProviderName: WideString; const CommandText: WideString; 
  138.                          var Params: OleVariant; var OwnerData: OleVariant);
  139.     function  GetDatabaseNames: OleVariant;
  140.     procedure SetDatabaseName(const DBName: WideString; const Password: WideString);
  141.     property  DefaultInterface: IAdHocQueryDemo read GetDefaultInterface;
  142.   published
  143.     property Server: TAdHocQueryDemoProperties read GetServerProperties;
  144.   end;
  145.  
  146. // *********************************************************************//
  147. // OLE Server Properties Proxy Class
  148. // Server Object    : TAdHocQueryDemo
  149. // (This object is used by the IDE's Property Inspector to allow editing
  150. //  of the properties of this server)
  151. // *********************************************************************//
  152.  TAdHocQueryDemoProperties = class(TPersistent)
  153.   private
  154.     FServer:    TAdHocQueryDemo;
  155.     function    GetDefaultInterface: IAdHocQueryDemo;
  156.     constructor Create(AServer: TAdHocQueryDemo);
  157.   protected
  158.   public
  159.     property DefaultInterface: IAdHocQueryDemo read GetDefaultInterface;
  160.   published
  161.   end;
  162.  
  163. procedure Register;
  164.  
  165. implementation
  166.  
  167. uses ComObj;
  168.  
  169. class function CoAdHocQueryDemo.Create: IAdHocQueryDemo;
  170. begin
  171.   Result := CreateComObject(CLASS_AdHocQueryDemo) as IAdHocQueryDemo;
  172. end;
  173.  
  174. class function CoAdHocQueryDemo.CreateRemote(const MachineName: string): IAdHocQueryDemo;
  175. begin
  176.   Result := CreateRemoteComObject(MachineName, CLASS_AdHocQueryDemo) as IAdHocQueryDemo;
  177. end;
  178.  
  179. procedure TAdHocQueryDemo.InitServerData;
  180. const
  181.   CServerData: TServerData = (
  182.     ClassID:   '{85C677A2-F92F-11D0-9FFC-00A0248E4B9A}';
  183.     IntfIID:   '{85C677A1-F92F-11D0-9FFC-00A0248E4B9A}';
  184.     EventIID:  '';
  185.     LicenseKey: nil;
  186.     Version: 500);
  187. begin
  188.   ServerData := @CServerData;
  189. end;
  190.  
  191. procedure TAdHocQueryDemo.Connect;
  192. var
  193.   punk: IUnknown;
  194. begin
  195.   if FIntf = nil then
  196.   begin
  197.     punk := GetServer;
  198.     Fintf:= punk as IAdHocQueryDemo;
  199.   end;
  200. end;
  201.  
  202. procedure TAdHocQueryDemo.DisConnect;
  203. begin
  204.   FIntf := nil;
  205. end;
  206.  
  207.  
  208. function TAdHocQueryDemo.GetDefaultInterface: IAdHocQueryDemo;
  209. begin
  210.   Connect;
  211.   Result := FIntf;
  212. end;
  213.  
  214. constructor TAdHocQueryDemo.Create(AOwner: TComponent);
  215. begin
  216.   inherited Create(AOwner);
  217.  
  218.   FProps := TAdHocQueryDemoProperties.Create(Self);
  219. end;
  220. destructor TAdHocQueryDemo.Destroy;
  221. begin
  222.   FProps.Free;
  223.   inherited Destroy;
  224. end;
  225. function TAdHocQueryDemo.GetServerProperties: TAdHocQueryDemoProperties;
  226. begin
  227.   Result := FProps;
  228. end;
  229.  
  230. function  TAdHocQueryDemo.AS_ApplyUpdates(const ProviderName: WideString; Delta: OleVariant; 
  231.                                           MaxErrors: Integer; out ErrorCount: Integer; 
  232.                                           var OwnerData: OleVariant): OleVariant;
  233. begin
  234.   Result := DefaultInterface.AS_ApplyUpdates(ProviderName, Delta, MaxErrors, ErrorCount, OwnerData);
  235. end;
  236.  
  237. function  TAdHocQueryDemo.AS_GetRecords(const ProviderName: WideString; Count: Integer; 
  238.                                         out RecsOut: Integer; Options: Integer; 
  239.                                         const CommandText: WideString; var Params: OleVariant; 
  240.                                         var OwnerData: OleVariant): OleVariant;
  241. begin
  242.   Result := DefaultInterface.AS_GetRecords(ProviderName, Count, RecsOut, Options, CommandText, 
  243.                                            Params, OwnerData);
  244. end;
  245.  
  246. function  TAdHocQueryDemo.AS_DataRequest(const ProviderName: WideString; Data: OleVariant): OleVariant;
  247. begin
  248.   Result := DefaultInterface.AS_DataRequest(ProviderName, Data);
  249. end;
  250.  
  251. function  TAdHocQueryDemo.AS_GetProviderNames: OleVariant;
  252. begin
  253.   Result := DefaultInterface.AS_GetProviderNames;
  254. end;
  255.  
  256. function  TAdHocQueryDemo.AS_GetParams(const ProviderName: WideString; var OwnerData: OleVariant): OleVariant;
  257. begin
  258.   Result := DefaultInterface.AS_GetParams(ProviderName, OwnerData);
  259. end;
  260.  
  261. function  TAdHocQueryDemo.AS_RowRequest(const ProviderName: WideString; Row: OleVariant; 
  262.                                         RequestType: Integer; var OwnerData: OleVariant): OleVariant;
  263. begin
  264.   Result := DefaultInterface.AS_RowRequest(ProviderName, Row, RequestType, OwnerData);
  265. end;
  266.  
  267. procedure TAdHocQueryDemo.AS_Execute(const ProviderName: WideString; const CommandText: WideString; 
  268.                                      var Params: OleVariant; var OwnerData: OleVariant);
  269. begin
  270.   DefaultInterface.AS_Execute(ProviderName, CommandText, Params, OwnerData);
  271. end;
  272.  
  273. function  TAdHocQueryDemo.GetDatabaseNames: OleVariant;
  274. begin
  275.   Result := DefaultInterface.GetDatabaseNames;
  276. end;
  277.  
  278. procedure TAdHocQueryDemo.SetDatabaseName(const DBName: WideString; const Password: WideString);
  279. begin
  280.   DefaultInterface.SetDatabaseName(DBName, Password);
  281. end;
  282.  
  283. constructor TAdHocQueryDemoProperties.Create(AServer: TAdHocQueryDemo);
  284. begin
  285.   inherited Create;
  286.   FServer := AServer;
  287. end;
  288.  
  289. function TAdHocQueryDemoProperties.GetDefaultInterface: IAdHocQueryDemo;
  290. begin
  291.   Result := FServer.DefaultInterface;
  292. end;
  293. procedure Register;
  294. begin
  295.   RegisterComponents('Servers',[TAdHocQueryDemo]);
  296. end;
  297.  
  298. end.
  299.