Library tutorials & articles

API Programming Series #2

Aliasing

Aliasing is a technique used to call a function with a different name than its original name as defined in the DLL to avoid naming problems ambiguities etc. Occasionally, a DLL procedure has a name that is not a legal identifier. It might have an invalid character (such as a hyphen), or the name might be the same as a Visual Basic keyword (such as GetObject). When this is the case, use the Alias keyword to specify the illegal procedure name.

For example, some procedures in the operating environment DLLs begin with an underscore character. While you can use an underscore in a Visual Basic identifier, you cannot begin an identifier with an underscore. To use one of these procedures, you first declare the function with a legal name, then use the Alias clause to reference the procedure's real name.

We can also use the Alias clause to change a procedure name whenever it's convenient say, to remove the ambiguity problem discussed earlier in this article. If you do substitute your own names for procedures, make sure that you thoroughly document the changes so that your code can be maintained at a later date.

In our example therefore, GetComputerNameA is the name of the function and GetComputerName is its alias. This could be confusing the first time around. Don't worry; it's simple once you get the hang of it.

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

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!