PMV wrote:Code: Select all
mylib = OpenLibrary(#PB_Any, "mylib.dll")
If IsLibrary(mylib)
;do whatever action you had in mind
CloseLibrary(mylib)
Endif
This code is nonsense. You are wasting CPU power checking something that you already know.
The returnvalue of OpenLibrary() tells you wether the call succeeded or not. If it fails you get 0, otherwise it succeeded. That value is all you need to check...
Code: Select all
mylib = OpenLibrary(#PB_Any, "mylib.dll")
If mylib
;do whatever action you had in mind
CloseLibrary(mylib)
Endif
Keep this in mind:
All IsXXX() commands are expensive operations, because the only way to validate #PB_Any objects is to
look at all of them and see if one matches. That won't matter if you have just two libraries open but if we are talking about a few hundred gadgets or images, things look different. So better don't get into that habit.
In fact: A correctly written program should have no need to call any IsXXX() function ever since you can always tell on object creation whether it succeeded or failed, and you know when you free the object so there is no reason for a confusion of weather an object is valid or not. These functions are a debugging tool, nothing else.