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