If Environ("Username" doesn't do it it's an API call which I don't have a record of!
;-)
If a man says something and there are no women there to hear him, is he still wrong?
The faqs ma'am, just the faqs. Get the best from these forums : faq222-2244
[tt]Public Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function ReturnComputerName() As String
Dim rString As String * 255, sLen As Long, tString As String
tString = ""
On Error Resume Next
sLen = GetComputerName(rString, 255)
sLen = InStr(1, rString, Chr(0))
If sLen > 0 Then
tString = Left(rString, sLen - 1)
Else
tString = rString
End If
On Error GoTo 0
ReturnComputerName = UCase(Trim(tString))
End Function
[/tt]
I hope that these posts have helped you!
Peace!!
Mike
Didn't get the answers that you wanted? Take a look at FAQ219-2884
I just had to give a star to Loomah for the Environ("Username" and also to DrBowes for demonstrating how to use it as a function. This has helped me solve a problem I had with obtaining username, computername etc
I now use:
Function GetUser()
GetUser = Environ("Username"
End Function
Function GetComputer()
GetComputer = Environ("Computername"
End Function
Function GetOS()
GetOS = Environ("OS"
End Function
Is there a list anywhere that shows what arguments you can use with environ ? I couldn't find anything in the help
waynerenaud - See Mike's (Bowers74) post - his 1st comment is a link to a FAQ on just this subject
Rgds, Geoff [blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.