Get login name/user name
Posted on 2001-06-18
I can get the login name by using either:
Declare Function WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Both works fine when executed. My problem is that I want to execute my program (exe-file) from a login script (NT or Novell) and write the login name to a file.
All I get is an empty string. Looks like Windows can't return the info this early in the startup process.
The main reason for running the code from a login script, is that I don't have to install any program on the clients.
The program works fine if I launch it from the Startup-folder.
Any suggestions? Is there other ways to return the login name?