If I make use of a Type Library in a VB6 project do I need to distribute the .tlb file (and perhaps even re开发者_运维百科gister it?) with the compiled exe on the target computer?
No, usually it is only needed if you actually call code that attempts to use the types from the type library. I have found some exceptions, involving using types from the type library to dimension variables. I think it was something like this...
Supposing the type library defines a structure A, and your app contains a procedure like this. If the type library is not registered your app cannot start - an error message is displayed.
Sub testSub1(ByRef mybadarray() As A)
but this would be OK
Sub testSub2()
Dim ok As A ' OK provided you never actually Call testSub2 at runtime '
In my experience, I always distribute .TLB file along with .EXE including registration, it helped me to prevent the multiple run-time errors like "Run-time error '429': ActiveX component can't create object".
No you don't. It's only used at compile time.
Only if you are using multi-threading, i.e. ActiveX EXEs or in-proc with CoMarshalInterThreadInterfaceInStream
etc. functions.
精彩评论