Board index » delphi » OLE typelibs - getting at exposed object info

OLE typelibs - getting at exposed object info

Development environment:  Delphi 2.0 Professional

I'm writing an OLE controller application and need to know how I get to
object information exposed by the OLE server application via an OLE type
library (*.tlb).  I've done this via Visual C++ 4.2, which allows you to
import the information via classwizard, but I've been unable to find a
similar feature in Delphi 2.0.  I even downloaded the "updated" Help files
from the Borland site, and nothing there seems to point me in the right
direction.

I have no problems interacting with the OLE server application in most
situations (it starts, I can call methods, etc.), so I know it's been
registered appropriately (as an .ocx).  However, one function call returns
a structure which I know is defined in this library (using MS oleview.exe),
but when I define a variable of this type, Delphi complains about an
undefined type.

Just in case someone reading this is curious, the OLE server application is
MapInfo's MapMarker (http://www.mapinfo.com).  The structures I'm trying to
access are CAddressList and CAddress.

P.S.  Please respond via e-mail if you have some input, as I only get to
the news servers about once a week.

--
Lou Konior
Wye Consulting Group
l...@wyegroup.com
http://www.wyegroup.com

 

Re:OLE typelibs - getting at exposed object info


Quote
Lou Konior wrote:
> Development environment:  Delphi 2.0 Professional

> I'm writing an OLE controller application and need to know how I get to
> object information exposed by the OLE server application via an OLE type
> library (*.tlb).  I've done this via Visual C++ 4.2, which allows you to
> import the information via classwizard, but I've been unable to find a

Upgrade to Delphi 3 and you can just do File->Open->*.tlb File.  That
opens up the Delphi 3 Type Library editor.  In Delphi 2 there is no
equavalent to the Class Wizard, though there are third party options, I
think.

Erik

Re:OLE typelibs - getting at exposed object info


Erik B. Berry <ebe...@sync-link.com.I.HEART.SPAM> wrote in article
<346B7757....@sync-link.com.I.HEART.SPAM>...

Quote

> Upgrade to Delphi 3 and you can just do File->Open->*.tlb File.  That
> opens up the Delphi 3 Type Library editor.  In Delphi 2 there is no
> equavalent to the Class Wizard, though there are third party options, I
> think.

> Erik

Great.  Any suggestions for 3rd party tools?  Or even better, anybody out
there know how to "hand job" a .pas file to do the same thing?  The
following are the important excerpts from the corresponding .IDL file:

            [id(0x00000023), helpstring("Retrieve a CAddressList collection
of Caddress objects")]
            IDispatch* GeocodeGetCandidates(
                            long geocodeHandle,
                            short numCandidates);

<...>

    [
      uuid(74C43670-DA62-11CF-ABF0-00AA00C1E1CF),
      helpstring("Dispatch interface for match candidate")
    ]
    dispinterface IAddress {
        properties:
            [id(0x00000001), helpstring("Candidate street name")]
            BSTR Street;
            [id(0x00000002), helpstring("Candidate city")]
            BSTR City;
            [id(0x00000003), helpstring("Candidate state abbreviation")]
            BSTR State;
            [id(0x00000004), helpstring("Candidate ZIP code")]
            BSTR Zip;
            [id(0x00000005), helpstring("Candidate Plus4")]
            BSTR plus4;
            [id(0x00000006), helpstring("Candidate longitude")]
            double Longitude;
            [id(0x00000007), helpstring("Candidate latitude")]
            double Latitude;
            [id(0x00000008), helpstring("Candidate US Census Block ID")]
            BSTR CensusBlock;
            [id(0x00000009), helpstring("Matching quality information and
field match indicators")]
            BSTR ResultCode;
            [id(0x0000000a), helpstring("Match precision 30-intersection,
20-street level, 10-shape path, 3-ZIP+4 centroid, 2-ZIP+2 centroid, 1-ZIP
centroid")]
            short Precision;
            [id(0x0000000b), helpstring("Canidate firm name")]
            BSTR Firm;
        methods:
    };

    [
      uuid(74C43671-DA62-11CF-ABF0-00AA00C1E1CF),
      helpstring("Match candidate")
    ]
    coclass CAddress {
        [default] dispinterface IAddress;
    };

    [
      uuid(445EB3B0-DA63-11CF-ABF0-00AA00C1E1CF),
      helpstring("Dispatch interface for match candidate list")
    ]
    dispinterface IAddressList {
        properties:
        methods:
    };

    [
      uuid(445EB3B1-DA63-11CF-ABF0-00AA00C1E1CF),
      helpstring("Match candidate list")
    ]
    coclass CAddressList {
        [default] dispinterface IAddressList;
    };

    [
      uuid(D3E3E570-DA64-11CF-ABF0-00AA00C1E1CF),
      helpstring("Match candidate collection")
    ]
    dispinterface ICollection {
        properties:
            [id(0x00000001), helpstring("Number of candidates in the
collection")]
            long Count;
        methods:
            [id(0x00000002)]
            IDispatch* Item(VARIANT index);
    };

    [
      uuid(D3E3E571-DA64-11CF-ABF0-00AA00C1E1CF),
      helpstring("Match candidate collection")
    ]
    coclass COLLECTION {
        [default] dispinterface ICollection;
    };

Quote
};

--
Lou Konior
Wye Consulting Group
l...@wyegroup.com
http://www.wyegroup.com

Re:OLE typelibs - getting at exposed object info


Quote
Lou Konior wrote:
> Great.  Any suggestions for 3rd party tools?  Or even better, anybody out
> there know how to "hand job" a .pas file to do the same thing?  The
> following are the important excerpts from the corresponding .IDL file:

I don't know the names of any third party tools, but I think Iona makes
or is making a CORBA IDL to Delphi conversion tool.  I seem to remember
one for COM being mentioned also, but I'm not sure.  I could translate
the .tlb file for you into Delphi 3 syntax, but it will use the new
inerface/dispinterface keywords that are part of D3's new Object Pascal
compiler, so it wouldn't work for D2.  Nonetheless, it might help you
with your project, and I'd be happy to send you the conversion.  If you
want the interface directly imported into Delphi 2, I know of nothing
that can help you.  Just do it manually, I guess.

Erik

Re:OLE typelibs - getting at exposed object info


Erik B. Berry <ebe...@sync-link.com.I.HEART.SPAM> wrote in article

Quote
> I could translate
> the .tlb file for you into Delphi 3 syntax, but it will use the new
> inerface/dispinterface keywords that are part of D3's new Object Pascal
> compiler, so it wouldn't work for D2.

Thanks a million for your help and your offer.  The time I spent
researching the problem would have paid for a Delphi 3 upgrade... So I'm
buying an updated copy this morning (I've been away from Delphi for about a
year, and didn't want to pry open my wallet).

--
Lou Konior
Wye Consulting Group
l...@wyegroup.com
http://www.wyegroup.com

Other Threads