Author Topic: SOLVED: Is there a bass.tlb Type Library ?  (Read 175 times)

jpf

  • Posts: 42
SOLVED: Is there a bass.tlb Type Library ?
« on: 29 Jul '17 - 00:28 »
On VB6, I've used referencing through existing tlb files quite often, and they make the coding work a lot easier.

Now I've read that referencing dll libraries through tlb files is safer and faster than using Declare statements:

https://www.experts-exchange.com/questions/20477929/reference-to-win-tlb-vs-explicit-declarations.html
Quote
-Faster function execution because the program links to the dll using the entry point specified inside the type library.  This doesn't happen with declare statements because all they have is the dll name.  Compiled code with declare statements will have to use LoadLibrary(), then GetProcAddress() before they can execute the procedure.

-Avoid remembering to put declare statements and constants and type declarations. :)

-Avoid some thread-unsafe issues in the VB6 runtime libraries when you attempt to multithread in VB6.  This is a consequence of the first advantage.

I'm specially interested in the 3rd advantage, because I've experienced runtime crashes when using VB6 functions to be called as callbacks from Bass. Typical case: when the same callback function is called from more than one Bass channel.

I don't know if referencing Bass through a tlb would help, but I'd like to give it a try. Unless someone here knows better.

I'm aware that VB6 runtime is not the best environment for Bass, but even so.

I'm a complete ignorant regarding tlb generation, else I'd try to generate some myself. But maybe someone here has already done the work. If so, maybe he/she'd be so kind as to share it.

Thanks in advance!
 
« Last Edit: 29 Jul '17 - 16:08 by jpf »

saga

  • Posts: 2180
Re: Is there a bass.tlb Type Library ?
« Reply #1 on: 29 Jul '17 - 13:27 »
Quote
-Faster function execution because the program links to the dll using the entry point specified inside the type library.
This is hardly relevant anywhere. Calling LoadLibrary followed by GetProcAddress isn't anywhere near "slow", not even in 2003.

Quote
-Avoid remembering to put declare statements and constants and type declarations.
Also irrelevant because bass.bas already exists and is ready to use. You cannot forget anything here.

Quote
I'm specially interested in the 3rd advantage, because I've experienced runtime crashes when using VB6 functions to be called as callbacks from Bass. Typical case: when the same callback function is called from more than one Bass channel.
This doesn't sound like something that is going to be fixed by using Type Libraries. The quote from that page is very vague about how this is supposed to help you, but I am very sure that a Type Library will not put any synchronization helpers around your own code. If you want be able to use your own code from multiple threads in callbacks, you yourself have to make sure that your own code is safe for multithreading, e.g. by using a critical section or not accessing any global state from that function.

jpf

  • Posts: 42
Re: Is there a bass.tlb Type Library ?
« Reply #2 on: 29 Jul '17 - 16:07 »
Thanks, Saga. You made your points very clear. So I reckon there's no reason to go for tlb referencing instead of Declares. Thanks!