>I believe the declaration needs to be
>
> Private Declare Function WNGetUser Lib "mpr.dll" _
> Alias "WNetGetUserA" (ByVal lpName As String, _
> ByVal lpUserName As String, lpnLength As Long) As Long
>
> --
> Doug Steele, Microsoft Access MVP
>
http://I.Am/DougSteele> (no e-mails, please!)
>
>
> "Julia Boswell" <jcrackne[ at ]hotmail.com> wrote in message
> news:O9HDemzKGHA.1032[ at ]TK2MSFTNGP11.phx.gbl...
>> Hi all,
>>
>> I'm new to API calls and have used some code I got on a training course,
>> which is giving me an error message. I haven't got a clue what the
>> problem
>> is (have searched google but to no avail). Can anyone help me please? The
>> code is:
>>
>> Public strUserName As String
>>
>> 'API Declaration - uses WNGetUser as alias
>> Private Declare Function WNGetUser Lib "mpr.dll" _
>> Alias "WNetGetUser" (ByVal lpName As String, _
>> ByVal lpUserName As String, lpnLength As Long) As Long
>>
>> Function fnBSIGetUserName() As Boolean
>> Dim lngRet As Long
>> strUserName = Space(256)
>> lngRet = WNGetUser("", strUserName, 256)
>> If lngRet = 0 Then
>> strUserName = LCase(Left(strUserName, InStr(strUserName,
>> Chr(0)) -
>> 1))
>> fnBSIGetUserName = True
>> Else
>> MsgBox "There was a problem retrieving the user name", vbCritical
> +
>> vbOKOnly, "Error!"
>> fnBSIGetUserName = False
>> End If
>> End Function
>>
>> I have checked and mpr.dll exists on my C drive.
>>
>> Any ideas gratefully received.
>>
>> Julia
>>
>>
>
>