When an ActiveX is imported into Delphi, a unit is generated (.pas source) that contains the wrappers for the various objects contained in the DLL, as well as for objects referenced by the DLL. The objects referenced by the DLL are those objects that are not implemented by the DLL, but are used as in/out arguments to one or more methods/properties.
A good example is the ChilkatCert object, which is contained in ChilkatCert.dll, but is referenced by Chilkat Mail, Crypt, FTP2, HTTP, etc. Unfortunately, because of the way Delphi generates the code, objects such as IChilkatCert must be typed specific to a type library. For example:
cert : CHILKATMAILLib2_TLB.IChilkatCert;
If the same IChilkatCert2 object is passed between objects from different type libraries, it needs to be cast using the "As" Delphi operator/keyword. Here’s an example where the IChilkatEmail2 object is used by both the Mail and MHT ActiveX’s:
mailman : TChilkatMailMan2;
mht : TChilkatMht;
email : CHILKATMAILLib2_TLB.IChilkatEmail2;
mailman := TChilkatMailMan2.Create(nil);
mht := TChilkatMht.Create(nil);
// If we do not cast here, you'll get this error:
// Incompatible types: 'CHILKATMHTLib_TLB.IChilkatEmail2' and 'CHILKATMAILLib2_TLB.IChilkatEmail2'
email := mht.GetEmail(‘C:\Content.html') <strong>As CHILKATMAILLib2_TLB.IChilkatEmail2</strong>;
// No cast is required here because email is declared specific to CHILKATMAILLib2_TLB
success := mailman.SendEmail(email);
if (success <> 1) then
PS> Here’s a reference page for the "As" keyword: Delphi As