Use COM object made with Borland C++ Builder

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi,

I have a COM object in a dll and it is registered on the system.
The COM object was made with Borland C++ Builder and works nicely when used
in BC++ projects.

I'm TOTALLY new to .NET (first day) and I have no clue how to use make use
of the COM object.
I made a small test app with a button and now I'm stuck ;-))

I have the *_TLB.cpp and *_TLB.h files of the COM object.

Some guidance would be really appreciated !
I'd like to get it to work in the test app, so that I can play with it and
learn how to use it.
 
Peter@Smart- said:
Hi,

I have a COM object in a dll and it is registered on the system.
The COM object was made with Borland C++ Builder and works nicely when used
in BC++ projects.

I'm TOTALLY new to .NET (first day) and I have no clue how to use make use
of the COM object.

If you're using VS.NET, simply add a reference to the COM object from
the references section of your project.
 
Thanks,
risking to sound very stupid now but ...
how do I add a reference to the COM object ?
(like said, very new to VS.NET)
 
Thanks,
how do I add a reference to the COM object ?
(like said, very new to VS.NET)

Go to the "Project" menu. Click "Add Reference..." Click on the "COM"
tab and select the COM object from the list presented.

It actually creates a .NET wrapper that makes your COM object look like
a .NET object (a "Runtime callable wrapper" or simply "RCW").
 
Seemed to work very smoothly !
Still some more confusion however,

One of the functions in the COM object (in C++) is :

SelectDrive(unsigned_char DriveLetter/*[in]*/, void** DriveHandle/*[out]*/)

Input is a char, for instance 'd'
Output is a pointer to a HANDLE of an object (the handle is used to pass to
other functions of the COM object)
(in C++ HANDLE is a pointer to void and because it's output of the function,
the output is a pointer to a pointer of void (void**))

..NET seems to make this of this function :

public abstract new void SelectDrive ( System.Byte DriveLetter ,
System.IntPtr DriveHandle )

I don't seem to understand .NET (yet) because I can't write a few simple
lines that use the COM object.
I find it strange that I seem to have to pass an entire object each time,
instead of a simple variable ?
I tried numerous things, then tried the classes as they are used in the
function template made by .NET
This was the last attempt :

System.IntPtr Drive ;
System.Byte DriveLetter = (byte)'D' ;
DllName.InterfaceName.SelectDrive(DriveLetter, Drive) ;

I still get compiler errors ...
An object reference is required for the nonstatic field, method, or property
'Perlustro.ICDDVDIO.SelectDrive(byte, out System.IntPtr)'

Can anybody give a few simple lines of code showing me how to do this !
I don't have the time right now to completely dig into .NET
I just need to be able to demonstrate the use of the COM object in .NET

Thanks !
Peter
 
I tried numerous things, then tried the classes as they are used in the
function template made by .NET
This was the last attempt :

System.IntPtr Drive ;
System.Byte DriveLetter = (byte)'D' ;
DllName.InterfaceName.SelectDrive(DriveLetter, Drive) ;

I still get compiler errors ...
An object reference is required for the nonstatic field, method, or property
'Perlustro.ICDDVDIO.SelectDrive(byte, out System.IntPtr)'

Like COM, you still need to create an instance of the object before
calling any of its methods:

InterfaceName the_object = new XXX();
the_object.SelectDrive(DriveLetter, out Drive);
 
Back
Top