title: Using methods from a COM class in Delphi
body: <p>I have a COM class created in VB.NET.  I am trying to use it in Delphi 5.0.</p>
  
  <p>I have seen some examples/questions on the topic, namely:</p>
  
  <p><a href="https://stackoverflow.com/questions/6174584/call-c-sharp-dll-from-delphi">Call C# dll from Delphi</a></p>
  
  <p><a href="http://www.drbob42.com/delphi/headconv.htm" rel="nofollow noreferrer">http://www.drbob42.com/delphi/headconv.htm</a></p>
  
  <p><a href="http://edn.embarcadero.com/article/32754" rel="nofollow noreferrer">http://edn.embarcadero.com/article/32754</a> </p>
  
  <p>and others, but these all deal with basic functions and not custom objects.</p>
  
  <p>Firstly, I have registered my VB.NET COM DLL using <code>regasm</code>.</p>
  
  <p>My VB.NET COM object is defined as follows:</p>
  
  <pre class="lang-vb prettyprint-override"><code>&lt;ComClass(Bridge.ClassId, Bridge.InterfaceId, Bridge.EventsId)&gt; _
  Public Class Bridge
  
    ' A creatable COM class must have a Public Sub New() 
    ' with no parameters, otherwise, the class will not be 
    ' registered in the COM registry and cannot be created 
    ' via CreateObject.
    Public Sub New()
      MyBase.New()
    End Sub
  
    Public Function Quote(ByRef input As InObject) As ReturnObject
      BLABLA
    End Function
  
  End Class
  </code></pre>
  
  <p>With an Input class:</p>
  
  <pre class="lang-vb prettyprint-override"><code>&lt;ComClass(InObject.ClassId, InObject.InterfaceId, InObject.EventsId)&gt; _
  Public Class InObject
  
  End Class
  </code></pre>
  
  <p>And a Result class:</p>
  
  <pre class="lang-vb prettyprint-override"><code>&lt;ComClass(ReturnObject.ClassId, ReturnObject.InterfaceId, ReturnObject.EventsId)&gt; _
  Public Class ReturnObject
  
  End Class
  </code></pre>
  
  <p>Please pay no attention to the class names and lack of code in them.  I just want to highlight how I am defining them as COM classes.</p>
  
  <p>I can't find any examples of Delphi code calling a method in a COM class, or one that uses custom objects as inputs and returns.  But, from the examples I showed above, I thought the line in Delphi to declare the function for use would be like this:</p>
  
  <pre class="lang-pascal prettyprint-override"><code>function Bridge.Quote(i: InObject): ReturnObject; external 'Bridge.dll';
  </code></pre>
  
  <p>This fails to compile.  I get an error:</p>
  
  <blockquote>
    <p>function needs result type</p>
  </blockquote>
  
  <p>Is there anything obvious that I am doing wrong?</p>