Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
swdev:howto:develop_com_components_and_automation [2009/10/06 11:31]
smayr
swdev:howto:develop_com_components_and_automation [2009/11/05 11:12] (current)
smayr
Line 78: Line 78:
 procedure TfrmClientMain.btnLaunchSvrClick(Sender: TObject); procedure TfrmClientMain.btnLaunchSvrClick(Sender: TObject);
 begin begin
-  svr    := CoMySvr.Create();+  if not Assigned(svr) then begin 
 +    svr := CoMySvr.Create()
 +  end;
   if Assigned(svr) then begin   if Assigned(svr) then begin
     btnGetSvrVersion.Enabled := True;     btnGetSvrVersion.Enabled := True;
Line 91: Line 93:
  
 == Wrapping an Existing Application Functionality in an Automation Object == == Wrapping an Existing Application Functionality in an Automation Object ==
 +Especially use this method for Out-of-process automation servers:
  * Open an existing Delphi application project.   * Open an existing Delphi application project. 
     * Select New > ActiveX > Automation Object.     * Select New > ActiveX > Automation Object.
Line 98: Line 101:
       * Select ''IMySvr'', then add Method or Property.       * Select ''IMySvr'', then add Method or Property.
  * Register the COM Server.  Perform one of these:  * Register the COM Server.  Perform one of these:
-    * Select Run > Register ActiveX Server. +    * In-process (DLL) automation server: 
-    * Setup project to auto register server, to avoid littering the Windows Registry while developing.  +      * Select Run > Register ActiveX Server. 
-      * Select Project > Options > Linker > Auto register type library.+      * Setup project to auto register server, to avoid littering the Windows Registry while developing.  
 +        * Select Project > Options > Linker > Auto register type library. 
 +      * Register from command line: <code>C:\> regsvr32 myServer.dll </code> or <code>C:\> tregsvr myServer.dll</code> 
 +    * Out-of-process (EXE) automation server: 
 +      * To register, run this from command line: <code>C:\> myapp.exe /regserver </code> 
 +      * To unregister, run this from command line: <code>C:\> myapp.exe /unregserver </code>
  
 == Linking Multiple Clients to a Single Instance of a COM Object == == Linking Multiple Clients to a Single Instance of a COM Object ==
Line 355: Line 363:
  * [[http://msdn2.microsoft.com/en-us/library/ms221145.aspx|MSDN Safearray Manipulation Functions]] - Microsoft MSDN  * [[http://msdn2.microsoft.com/en-us/library/ms221145.aspx|MSDN Safearray Manipulation Functions]] - Microsoft MSDN
  * [[http://www.gekko-software.nl/Delphi/art08.htm|Automation Arrays (Safearray, Variant arrays)]] - Gekko Software  * [[http://www.gekko-software.nl/Delphi/art08.htm|Automation Arrays (Safearray, Variant arrays)]] - Gekko Software
 + * [[http://www.gekko-software.nl/Delphi/art10.htm|Server Events for Two-way Communication]] - Gekko Software
 + * [[http://www.techvanguards.com/com/|COM Tutorials and Concepts]] - TechVanguards
 + * [[http://podgeretsky.com/ftp/docs/Delphi/D5/dg/autosrvr.html#3201|Delphi 5 Dev Guide: Creating an Automation Server]]