Computer Science Canada

API (Application Programming Interface)

Author:  Random [ Sat Nov 06, 2004 3:24 pm ]
Post subject:  API (Application Programming Interface)

Well, this is my first tutorial, and it isn't that great. If im not clear on something (which im sure im not) tell me and ill try to explain it better. Thanks for your time.

Using API in your application really makes life easier and allows you to do more advanced things in Visual Basic. API's are basically functions compiled into DLL's or other files of the sort that you call to do your bidding. They are usually written in C/C++ so they are quicker than code written in VB. They are there so that people dont have to spend tons of time writing code to do something, when someone already wrote the code you need.

Before using an API, you need to have the file (usually a DLL) which the API is located in. Windows comes with a ton of these functions and the easiest way to learn about different ones and what they do is the internet.

code:

'first you need to declare an API call.  A good place to do all your API declarations is in a seperate module.
Public Declare Function ShowCursor& Lib "user32" (ByVal bShow As Long)

'Then you need to call it.  For example, at the event of a button being hit, execute the function.
ShowCursor (False)

'now the cursor will disapear.  To show it again, use the below.
ShowCursor (True)


There are many API's that are very useful. To find the declaration statement for them, you can search on the web, or use the tool "Apiload.exe" that comes with visual basic. You can use it to load one of the text files that is packaged with visual basic that contains the declarations for different API's.

As to finding out what different API's do, as far as I know you need to search the internet. That is what I do atleast. I hope this helps you in writing programs in Visual Basic.


: