title: Convert OleVariant to Object in Delphi
body: <p>I'm working on this project where we don't have the source code for large chunks of the project, but we have the .DLL files with some information.  There is a bug in the DLL files.  I am able to create a subclass of the class with the bug in it and I would like to downcast the object which already exists at a point I have access to it.  The issue is that at any point I have access to the object, it's cast as a Variant.  I've tried the following (edited to remove context):</p>
  
  <pre><code>tempSubclass := Subclass(ParentClass(Integer(oleVariantCast)));
  </code></pre>
  
  <p>but I get the following error:</p>
  
  <pre><code>Could not convert variant of type (Dispatch) into type (Integer)
  </code></pre>
  
  <p>Is there any other way to get the pointer to the object out of the OleVariant and/or do the typecasting involved?</p>
  
  <p>Thank you.</p>
  
  <p>EDIT: Yes, the Parentclass implements IDispatch.
  CORRECTION: The parentclass implements an interface which inherits from IDispatch.</p>