title: COM Server application and GetObject - reusing the running application
body: <p>I'm trying to automate an application (Windows 8, Delphi XE.) For my testing I'm doing the following:</p>
  
  <ul>
  <li>Created a small test application, consisting of a form and a memo (Form1)</li>
  <li>Added a new ActiveX Object, CoClass name TestOLE, Threading mode Apartment, Instancing Multiple (as per <a href="http://www.techvanguards.com/com/tutorials/tips.htm#Understand%20the%20class%20factory%20Instancing%20property" rel="nofollow">this article</a>.)</li>
  <li>Added one method <code>Method1</code> which only adds some text to the memo control in Form1</li>
  </ul>
  
  <p>I then start the application and double click on a file named <code>test.vbs</code> which contains the following code:</p>
  
  <pre><code>dim obj
  set obj = GetObject("", "Project1.TestOLE")
  obj.AddSomeText "Hola mundo"
  </code></pre>
  
  <p>When the application is running, I see that a new form is created, the text is added and then it exits. </p>
  
  <p>What I want to accomplish is that the opened application should have its memo text changed.</p>
  
  <p>I've repeated creating new projects with both MultipleInstance and SingleInstance, and in an outburst of heuristic anger, I even changed the threading model to single, to no avail.</p>
  
  <p>I see two flags in the type library editor: "Replaceable" and "Aggregatable." However, selecting "Replaceable" ends up in an error in the generated RIDL file.</p>
  
  <p>I've been reading a lot about <code>GetObject</code>. It appears that its documentation is even wrong (it says you can omit the first parameter but I've found that doesn't work).</p>
  
  <p>Is this the right way to write an automation server in Delphi that can be reused?</p>