?
Solved

Need to call a COM Method from a third party dll file in delphi

Posted on 2008-10-16
4
Medium Priority
?
514 Views
Last Modified: 2013-11-23
I have a third party dll file that I need to use in order to access an api through. I have used DLL export viewer and the login function is a COM Method, with the name showing as IAPI::Login

Synopsis - Login(string companyname, int number, string username, string password) as string

I have registered the dll file (XYZApi.dll) on my computer and need to call the login function through a delphi app.

ANy ideas on how I would call this please?
0
Comment
Question by:ubernewb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 21

Accepted Solution

by:
developmentguru earned 2000 total points
ID: 22744531
If it is a COM object DLL, and you have registered the DLL then go to the Delphi main menu
Component | Import Component
choose Import a Type Library (click Next)
choose your COM object's type library from the list (Click Next)
Set the Palette Page for any components, unit directory name, etc (Click Finish)

That should import any COM object that is registered in the system.  Then just create an instance of the COM object and use it's methods.
0
 

Author Comment

by:ubernewb
ID: 22753703
Thanks for that but I cant implement the interface.

The interface in the code library is:

   IAPI = interface(IDispatch)
    ['{GUID}']
   function Login(companyname: widestring; number : Integer; username : widestring; password: widestring) : widestring; safecall;
    procedure ......;
    function  ......;
    function  ......;
   end;

I try to create a class on the main form:

   TMyInterfaceClass = class(TInterfacedObject, IAPI
   function Login(companyname: widestring; number : Integer; username : widestring; password: widestring) : widestring; safecall;
   procedure ......;
   function  ......;
   function  ......;
end;

When I try to compile I get the error messages:

Undeclared identifier: 'GetTypeInfoCount'
Undeclared identifier: 'GetTypeInfo'
Undeclared identifier: 'GetIDsOfNames'

I have found a similar problem here:

http://www.experts-exchange.com/Programming/Editors_IDEs/Delphi/Q_22948763.html

but when I implement the accepted answer ...

"teh IVBSAXContentHandler is an IDispatch interface. You ust also implement the functions from that interface.

you need to find a class that already implements those functions in order to extend from it. A barebone class would be TAutoIntfObject from comobj.

The most used is TComponent :)

so replace
TSAXContentHandler = class(TInterfacedObject, IVBSAXContentHandler)
with
TSAXContentHandler = class(TComponent, IVBSAXContentHandler)"

...I get the error:

Unsatisified forward or external declaration TMyInterfaceClass.Login

Any help would be appreciated

Thanks
0
 
LVL 21

Expert Comment

by:developmentguru
ID: 22754634
 The way you are going about it you are trying to write the code for the interface.  I thought you wanted to use an object that already exists.  If that is the case, follow the steps I gave in my first response.  Then you will not need to implement the interface, just use it.

  By declaring your own class (as using the interface) you are telling Delphi that you want to make your own class that supports the interface.  If this is what you want to do then you need to provide your own implementation of each of the interface methods.  The error you are getting tells you that:
A) You are trying to create a class that supports a specific interface
B) You have not defined the specific method (mentioned in the error) of the interface.
0
 

Author Closing Comment

by:ubernewb
ID: 31507055
Thanks for your help
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month9 days, 4 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question