Home.TutorialReferences
Home

  • Visual Basic & API
          So what is API in the first place? Simply put API or application programming interface is Windows' collection of DLLs (dynamic link libraries). These DLLs are procedures that make up the Microsoft Windows operating system. Each DLL controls different aspects of Windows, such as an error message or the blink rate of a cursor. Windows or other applications simply call upon the specific DLL to perform the desired task. The ability for Visual Basic to access these DLLs gives it an enormous amount of power. The power to perform tasks that would normally would be impossible to do without API.

  • Getting Started
          It is a very simple task to begin coding API functions in Visual Basic. The only difficulty part would be to find the specific DLL that performed that task desired. This is the point at which we reach for are many resources on this subject. In the Tutorial I will delve further into Visual Basics Add-In API Viewer that allows you to Browse through the many DLLs. Also there is a small list of references that you can use to gather more information on a particular DLL on this web site. Once you have chosen the DLL that you want to use in your project all that is needed are two things. First you must declare the DLL in a Module or a Form. When declaring a DLL within a Form you must use the "Private" statement before the delegation code such as in the code below.

    Private Declare Function ExitWindowsEx Lib "user32" _
    (ByVal uFlags As Long, ByVal dwReserved As Long) As Long


    If You Declare the DLL within a module then you simply leave out the "Private" statement. This is where the API Viewer comes in handy, because it allows you to search for the declaration and past it directly into your code. The next step is to call the DLL Function within the form. An example of calling the previous declaration is the code below.

    Dim ShutDown As Long
    ShutDown = ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)


    That's the simple cut and dry explanation of what API is and how to use it. Though this might seem a bit short it is more then enough to get you started on your way to programming with API. The next step you should take is to simply follow along with the tutorial.