graham_charles
asked on
reference to win.tlb vs. explicit declarations
I recently stumbled across a project that included a reference to win.tlb (the Windows type library), and because of that, didn't require explicit API declarations for a number of things, like SetActiveWindow, many API constants, etc.
Is that a reasonable thing to do? I've always declared the APIs I need explicitly in a code module, but if the declarations already exist in type libraries on every Windows system, it seems safer (?) to include the reference only?
Thanks for any comments.
Is that a reasonable thing to do? I've always declared the APIs I need explicitly in a code module, but if the declarations already exist in type libraries on every Windows system, it seems safer (?) to include the reference only?
Thanks for any comments.
What Is a Type Library?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap1_5mzj.asp
http://www.mvps.org/vb/hardcore/html/whatistypelibrary.htm
Windows API Type Library (Win32.tlb)
http://www.geocities.com/practicalvb/vb/download/win32.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap1_5mzj.asp
http://www.mvps.org/vb/hardcore/html/whatistypelibrary.htm
Windows API Type Library (Win32.tlb)
http://www.geocities.com/practicalvb/vb/download/win32.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wow, I'm convinced! One last question... am I going to have any trouble across different Windows versions, say back to Win95? I know some of these functions have evolved in that time...
Thanks,
g.
Thanks,
g.
Nope, I can't think of a case. But if you encounter a problem, try with a declare statement and recompile. If it works, most likely the entry point for the function was changed.
I am not saying in all cases, but in some situations you have to declare a specific API in a type library to prevent crashes when the APi is executed.
the type library is compiled into the application so the destination computers don't require the type library.
This is why it is better than using dll files.