This topic has not yet been rated - Rate this topic

Alias Clause (Visual Basic)

Indicates that an external procedure has another name in its DLL.

The Alias keyword can be used in this context:

Declare Statement

In the following example, the Alias keyword is used to provide the name of the function in advapi32.dll, GetUserNameA, that getUserName is used in place of in this example. Function getUserName is called in sub getUser, which displays the name of the current user.

Declare Function getUserName Lib "advapi32.dll" Alias "GetUserNameA" (
    ByVal lpBuffer As String, ByRef nSize As Integer) As Integer 
Sub getUser()
    Dim buffer As String = New String(CChar(" "), 25)
    Dim retVal As Integer = getUserName(buffer, 25)
    Dim userName As String = Strings.Left(buffer, InStr(buffer, Chr(0)) - 1)
End Sub
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.