Library tutorials & articles

API Programming Series #2

Problems when using API Text Viewer

However, you need to watch out for these common glitches:

If you copy the declarations right from the API Viewer, then remember to set the scope of the function appropriately. This can be done by setting the appropriate radiobutton. The scope is Public by default, the function has public scope. But VB does not allow public Declare statements within form modules. So if we are copying the Declare statements into a form module, they should be explicitly specified as Private, by clicking the appropriate radio button.

But this makes the declarations invisible outside the module in which they are defined. So the functions should be declared in every module that needs to use them, which can be pretty cumbersome in a large project. Declaring them in a separate .BAS module where they can be declared as Public and are therefore accessible to all the modules eliminates this duplication. This also permits easier maintenance.

Another common error is the Ambiguous Name detected error. Put simply this means that the module contains more than one function or constant having the same name, causing the ambiguity. Since most of the functions are Aliased, they are referred to by different names. In such cases we can change the function name at the declaration and invocation points and the code will work fine. (We will discuss aliasing in more detail, later on in this article)

There is one more error that you need to keep a really sharp eye out for, mainly because it comes from an unexpected source. The Win32api.txt file supplied by Microsoft contains some errors, which can cause you endless hours of frustration. Since we copy it from the API Viewer, the Declaration would be the last place we'd expect an error to arise especially as the file itself is a Microsoft product.

But sadly this file contains a number of errors that are particularly hard to track down. There's nothing much you can do about it, except of course to correct any that come to your attention and consult a good API guide or SDK documentation when things don't seem to go as expected.

The API-Guide created by the KPDTeam seems to be a very good replacement for the MS API viewer. It contains good explanations, examples and is structured in tree hierarchy that enables better comprehension.

It also comes with a good viewer which can be accessed as an Addin from within VB and is my choice whenever I do aPI programming.

Comments

  1. 29 May 2003 at 17:00

    The current release of the ApiViewer can now be found here:
    http://www.activevb.de/rubriken/apiviewer/index-apiviewereng.html


    or (German):
    http://www.ApiViewer.de

  2. 17 Dec 2002 at 12:44
    Nice job!! I really like the resource links and continued learning suggestions. I can't wait til my site is ready, so I can give back to the community. Stay Tuned!!
    charcoal
  3. 20 Nov 2002 at 02:25

    i'm faithfully following his series.

  4. 19 Nov 2002 at 11:46

    he's already posted part 4... i've just gotta get around to publishing 'em

  5. 19 Nov 2002 at 07:10

    i thought he was never gonna come back

  6. 01 Jan 1999 at 00:00

    This thread is for discussions of API Programming Series #2.

Leave a comment

Sign in or Join us (it's free).

Sreejath S. Warrier
AddThis

Related discussion

Related podcasts

  • Christian Beauclair

    14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...

Want to stay in touch with what's going on? Follow us on twitter!