?
Solved

Using a COM DLL in C++ Builder

Posted on 2003-03-25
7
Medium Priority
?
922 Views
Last Modified: 2013-11-25
I have been provided with a few DLLs which are COM servers, which were produced in Visual C++.  I can open these with Builder's TLB editor, and see all of their properties and methods, but I have no idea how to access them from the IDL file which I can produce there.  The TLB editor doesn't create a header file.  How am I to inform my program about the information in the DLL, in a way that I can create an instance and use the objects provided?

0
Comment
Question by:sburck
[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
  • 3
  • 3
7 Comments
 

Expert Comment

by:edd13579
ID: 8207669
The only way i know is to write your own.
0
 
LVL 2

Accepted Solution

by:
BorlandMan earned 2000 total points
ID: 8207947

Hi,
You might try using 'Import Type Library' under the project menu in the IDE (Integrated Development Environment)

If you don't mind me asking: why do you want to export to IDL?

Your COM objects are OLE/ActiveX Servers?  That is no visual display? Or are they active x controls?

I'm not sure how COM savvy you are, I'll assume your relatively new to it ok?

You said you are viewing the properties and methods in the typelib editor - good this is providing to you what you can call in the Interface.

If you import a type library into your project (there's some information in C++ Builder Help on this), c++ builder will create a .h file which contains information which will allow your application to connect to the dlls(com servers).

You then need to get an interface to the com object and can call the methods in that object.

check out the sample in C++ Builder
-> Examples\Doc\AutoProj\autocInt

this should give you a start or at least an idea of how to go about doing this.

take special note of the autocInt_tlb.h
it has a lot more than what you would typically expect for simple decls in a header file.

hth,
J
0
 
LVL 3

Author Comment

by:sburck
ID: 8208621
1)  You're correct, I'm generally an embedded developer, COM is relatively new to me.  

2) Import type library does seem to be the way to go.  There are 6 DLLs supplied, and most of them are importing, and I get the classes available.  

3)  There was a problem which I patched, I don't know how well - in each install, I got one compile error.  This function was created:

BSTR __fastcall get_DllName(BSTR* pVal/*[out,retval]*/)
  {
    return GetDefaultInterface()->get_DllName(pVal/*[out,retval]*/);
  }


and I had to add this cast

BSTR __fastcall get_DllName(BSTR* pVal/*[out,retval]*/)
  {
    return (BSTR)GetDefaultInterface()->get_DllName(pVal/*[out,retval]*/);
  }

to get it to compile.  Since I don't think I need this function, I'm hoping it won't be a problem.

In any case, I'll award you the points - there may be more questions down the line as I try to use the results.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Author Comment

by:sburck
ID: 8208626
Thanks again.
0
 
LVL 2

Expert Comment

by:BorlandMan
ID: 8210235
thanks for the points.

what version of c++ builder do you have? do you have the patches?  That might be a bug and a fix may be in a patch.

but it looks to be a simple cast there.

right now I don't have c++ builder on my machine (it's on my other one at another location)... but you might double check that the cast from the zero terminated string (e.g char szDllName[MAX_PATH]) is ok.  The BSTR as you probably know (or will discover) is a string, which can be passed across to other COM clients and Servers.. char* doesn't cut it.

good luck with the COM stuff.

Glad I was able to help you out.
J
0
 
LVL 3

Author Comment

by:sburck
ID: 8211329
It's Builder 6 with the latest (update 4) patch.  I'll see what Borland has to say about it.  Thanks again.

0
 
LVL 2

Expert Comment

by:BorlandMan
ID: 8211545

there actually was a mention about a 'beta' version of a new Type Library importer. It said something like there were a few potential bugs with code gen.

http://codecentral.borland.com/codecentral/ccweb.exe/listing?id=18865

not sure if this got rolled into BCB6 current patch yet.

hth,
J
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

762 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