Board index » delphi » Interface Mess

Interface Mess


2004-10-14 06:42:46 AM
delphi170
Hi Guys, im trying to use Tapi32.dll in my Delphi 6 conference application,
the Tapi 3.x exposes a Com Interface instead of the API and it is really
organized but the problem is when i import this Type Library to my project
all i see is interfaces , alot of them and only one object to play with
anyone can help me figure out how to deal with these interfaces and convert
them to classes or objects ?
 
 

Re:Interface Mess

Bishoy Ghaly writes:
Quote
Hi Guys, im trying to use Tapi32.dll in my Delphi 6 conference application,
the Tapi 3.x exposes a Com Interface instead of the API and it is really
organized but the problem is when i import this Type Library to my project
all i see is interfaces , alot of them and only one object to play with
anyone can help me figure out how to deal with these interfaces and convert
them to classes or objects ?
You've imported a COM type library, so you need to use COM. In COM,
everything is done via interfaces. You never get to see what class is
underneath, implementing the interface, unless you're the one writing
the implementation.
When you imported the type library, you wound up with declarations for a
handful of interfaces. Delphi also declared a helper class for you. You
can use that class to create instances of objects that implement the
corresponding interfaces. The implementation of the class's Create
function is very simple. It calls ComObj.CreateComObject, and all that
does is call the CoCreateInstance API function. That function loads the
TAPI DLL and calls functions in it that end up creating an object and
returning an interface reference.
Once you have an interface, you can call methods on it to do whatever
TAPI tasks it offers. For normal use, you can typically treat an
interface reference just as though it were an object reference.
Feel free to ask follow-up questions, but you might be better off asking
in one of Borland's COM or OLE Automation newsgroups.
--
Rob
 

Re:Interface Mess

Hi Rob,
Can you please take alook at Tapi32.dll Com import in Delphi6 or Delphi8
and tell me how can i convert those interfaces to normal classes cause when
i try to use an interface like a normal class i get an access violation, i
thank you for the help in advance.
Bishoy Ghaly
"Rob Kennedy" <.>writes news:XXXX@XXXXX.COM...
Quote
Bishoy Ghaly writes:
>Hi Guys, im trying to use Tapi32.dll in my Delphi 6 conference
>application, the Tapi 3.x exposes a Com Interface instead of the API and
>it is really organized but the problem is when i import this Type Library
>to my project all i see is interfaces , alot of them and only one object
>to play with
>anyone can help me figure out how to deal with these interfaces and
>convert them to classes or objects ?

You've imported a COM type library, so you need to use COM. In COM,
everything is done via interfaces. You never get to see what class is
underneath, implementing the interface, unless you're the one writing the
implementation.

When you imported the type library, you wound up with declarations for a
handful of interfaces. Delphi also declared a helper class for you. You
can use that class to create instances of objects that implement the
corresponding interfaces. The implementation of the class's Create
function is very simple. It calls ComObj.CreateComObject, and all that
does is call the CoCreateInstance API function. That function loads the
TAPI DLL and calls functions in it that end up creating an object and
returning an interface reference.

Once you have an interface, you can call methods on it to do whatever TAPI
tasks it offers. For normal use, you can typically treat an interface
reference just as though it were an object reference.

Feel free to ask follow-up questions, but you might be better off asking
in one of Borland's COM or OLE Automation newsgroups.

--
Rob
 

Re:Interface Mess

Bishoy Ghaly writes:
Quote
Can you please take alook at Tapi32.dll Com import in Delphi6 or Delphi8
Nope. I only have Delphi 5.
Quote
and tell me how can i convert those interfaces to normal classes cause when
i try to use an interface like a normal class i get an access violation, i
thank you for the help in advance.
How are you trying to use the interfaces?
To get an ITTAPI interface, you could go like this:
var
TAPI: ITTAPI;
TAPI := CoTAPI.Create;
If you had the "Generate component wrapper" check box checked when you
imported the type library, then Delphi also generated some automatic
components that can be registered on the Component Palette and dropped
onto forms and data modules. You can create a TTAPI object and use its
properties and methods, or you can use its DefaultInterface property to
get at the underlying ITTAPI interface.
--
Rob