Find out Who's Using your program, and where it's running


These two API calls are two of the most simple to use and understand.
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal_
lpBuffer As String, nSize As Long) As Long
Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal_
lpBuffer As String, nSize As Long) As Long
As you have probably guessed, GetUserName will tell you the name of the user who is currently logged on to your computer. This is especially useful under Windows NT where it is not possible to log on without supplying a user name and password. GetComputerName will tell you the name of the computer as defined under the network settings.
Since both of these functions use the same parameters, they can be described in the same way. The lpBuffer will hold the returned value of the function, either the user name or the computer name. The nSize will hold a value equal to the length of the returned string.



1