I am kind of biased but I think one of the most useful utilities in the Delphi or C++Builder bin directory is tlibimp.exe. In case you don't know what tlibimp.exe does, it allows you to use COM objects as if they are native interfaces, and .NET objects can be treated as COM objects, so there is a lot of potential here. This is the command line version of the Import Component Wizard, but who wants to use the IDE when we've got command line!
One of the most common problems users of Delphi run into only a few options are available from the IDE. Here is a list of all the options provided by tlibimp:
Borland TLIBIMP Version 11.0
Copyright (c) 1997-2005 Borland Software Corporation
Syntax: TLIBIMP [options]
Files to Generate (Required):
-C- C++ Import file
-P- PASCAL Import file
-Ic- CORBA IDL file
-Ip- PASCAL CORBA stubs & skeletons
Customize code generated:
-Ha+ Create IDE component for Controls
-Hs+ Create IDE component for Servers
-Hr+ Generate component registration
C++ options:
-Cd- Generate dispinterfaces
-Cm- Map disp interfaces to dual
-Cn
-Cs+ declspec(__selectany) for GUIDs
-Ct+ Force the use of a _TLB file
-Cu+ Expose namespace with 'using'
-Cv+ BCB4-style server events
-Cw- Use disp. in Control wrappers
Ignore Flags: -Ya- All special flags,
-Yh- [Hidden]
Debug Build Options:
-G+ Show Debug output
-Gr Read & write out type library
-It
Output File Options:
-D
-Fe
-Ft
-Ce
-Co
-Hpa
-Hps
PASCAL options:
-Ps+ Map dual HRESULT to safecall
-Pt- Map all HRESULT to safecall
MISC options:
-O+ Generate CoClassCreator wrappers
-R+ Process dependent type libraries
-XM- Use MS-style getter/setter
-W+ Emit warnings in files
-Wc+ Emit comments in files
-Yc+ [CanCreate],
-Yp- [Predefined], -Yr- [Restricted]
-Pu Generate Pascal UI file
-Xd+ Generate DispInterfaces
-Yi+ Ignore Standard Type Libraries
That's a lot of options. Some options are obsolete such as the CORBA options but we leave them in case they are being used.
Internally Delphi uses a lot of code generated by tlibimp to communicate to the .NET services such as MSBuild, the .NET designers, and a lot of internal services. The command line we use is:
tlibimp.exe -P+ -Ha- -Hr- -Hs- -R- -D
3 comments:
There wouldn't happen to be a way to turn off the insertion of the date in the header would there? Subversion constantly thinks my tlb.pas file has changed because, well, it has, but the *only* thing different is the date up in the header.
Granted it's not a huge deal but every time I see that I get just a little more more annoyed :)
Great post by the way. I wrote a gui utility awhile back that wraps up the command-line version because the ide-based version would go really wonky on me. No, I have no idea why I wrote a gui version instead of just scripting the command line but hey, it was a learing experience :)
Hi Shawn,
There is no option from the IDE. From the command line you can run -Wc- to turn off comments. If would be good to expose the command line options to the IDE.
Ahh, that makes sense when I actually think about it :) It would be nice to get some more control over the options the IDE uses. Seems msbuild could be brought into play here somehow to help with that but I'm talking off the cuff.
Post a Comment