TLB dependancies

adam8
adam8 used Ask the Experts™
on
If I add a TLB file to my references for an Standard EXE project will I need that TLB file if I compile the application.

For example if I distribute my program will the TLB file need to be installed with my program?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Yes the TLB will need to be installed!  When you derive objects of of a typelibrary, they get their definition from that typelibrary, not from what's in your code.  If you don't distribute it, it will act the same as if you don't distribute a DLL.

Author

Commented:
I thought maybe it got compiled with the program.

Author

Commented:
Hi,
I am not sure why I didn't try this before but I compiled the program and ran it on a destination computer with only the VB runtime files and no tthat depencandcy tlb and it ran and executed the API's within the TLB file. Even though it wasn't registered or installed on that computer.

I am confused.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

well, that makes two of us.  Are you sure you hit the functionality that requires the TLB when you tested (i.e. if command1_click is the only place you drum up one of these TLB objects, that you clicked on command1)?

It won't fail until you try to use the functionality within the TLB.

Author

Commented:
The tlb contains the postmessage API in the TimerProc sub to let the user know the time is up.

Without the postmessage API inside the TLB file the timer wouldn't be ticking, but it is ticking. Even on the computer without the TLB file.

By the way there is no PostMessage API call in the project. Just the reference tlb file attached to the project.

Author

Commented:
Have a look at this site. It is a tlb file containing lots of API references.

http://www.mvps.org/vb/hardcore/html/whatistypelibrary.htm

The bit that interests me is this part
"Your customers don’t need the Windows API type library to run programs that you develop using the type library"

Maybe TLB's do compile themself with the application.
Postmessage isn't involved in the timerproc routine by necessity.  If you are calling it within TimerProc and you have the on error resunme next, it could be bypassing the Postmessage altogether and then you wouldn't need the TLB.  The timerproc only needs the following API to do it's thing.  As long as that API is in your project, the timer will continue to run.


Private Declare Function SetTimer Lib "user32" _
  (ByVal hwnd As Long, _
   ByVal nIDEvent As Long, _
   ByVal uElapse As Long, _
   ByVal lpTimerFunc As Long) As Long
   
That is an interesting line.  I will test the theory out with my own typelibrary and see what happens.  Stand By.
Well, I'll be.  Seems you're right, it doesn't require it.  Must be compiling it into the EXE.  And here I've been doing it wrong all these years distributing the TLBs.  Thanks for pointing that out!

Author

Commented:
Hehe.

Um, just one question. How exactly do I make my own type libraries. I found the one I am using from a project but how do I make them?
Sorry, had to step away for a minute.  I use IDL a language outside of VB.  Then I use the MIDL compiler to compile the type library.  There are ways within VB to do it, but then VB steps in and creates a default interface that gets in the way of a lot of things.  Here's a MS site that shows an example of IDL:

http://support.microsoft.com/default.aspx?scid=KB;en-us;143258&

There's also another way if you have it.  You can use the MKTYPLIB.EXE program to make a typelibrary.  Haven't used it personally because VB still inserts the dfault interface that screws things up sometimes.

Author

Commented:
I realised that you can also use Delphi to do this.

Author

Commented:
What is this IDL language you speak of. Where can I obtain it?
IDL (Interface Definition Language) is a Microsoft tool.  It comes on the VC++ side of the house.  If you have the msdn, you will find the MIDL compiler In the VC\Bin directory after you install VC++.  (Or you can simply copy it from the CDs.  You can learn a lot about IDL by simply using the OLE Viewer on one of your own DLLs, OCSx, etc.  Using OLEViewer, you can copy and paste the IDL into notepad, tweak it to your liking and compile with the MIDL compiler.  Microsoft.com has some good articles on IDL.

Author

Commented:
ok.

thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial