w32_WNetGetUser not work Win98

  • Thread starter Thread starter Giovanni pepe
  • Start date Start date
G

Giovanni pepe

this is my code :

I convert this code from VB6...
Problem : lResult =487

Private Declare Function w32_WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA"
(ByVal lpszLocalName As String, ByVal lpszUserName As String, ByVal
lpcchBuffer As Integer) As Integer


Public Sub GetCurrentLogon16(ByVal UserName As String, ByVal DomainName As
String)
Dim lpUserName As String
Dim lpnLength As Integer
Dim lResult As Integer
Dim lpDomain As String

lpUserName = New String(Chr(0), 256)
lResult = w32_WNetGetUser("", lpUserName, 256)

If lResult = 0 Then
lpUserName = Left(lpUserName, InStr(1, lpUserName, Chr(0)) - 1)
UserName = lpUserName
DomainName = GetDomainFromRegistry()
End If

End Sub

How?
 
Hi,

WMI is not installed by default on Win98.

WMI Core
http://www.microsoft.com/downloads/...BA-337B-4E92-8C18-A63847760EA5&displaylang=en

Ken
--------------------------
this is my code :

I convert this code from VB6...
Problem : lResult =487

Private Declare Function w32_WNetGetUser Lib "mpr.dll" Alias "WNetGetUserA"
(ByVal lpszLocalName As String, ByVal lpszUserName As String, ByVal
lpcchBuffer As Integer) As Integer


Public Sub GetCurrentLogon16(ByVal UserName As String, ByVal DomainName As
String)
Dim lpUserName As String
Dim lpnLength As Integer
Dim lResult As Integer
Dim lpDomain As String

lpUserName = New String(Chr(0), 256)
lResult = w32_WNetGetUser("", lpUserName, 256)

If lResult = 0 Then
lpUserName = Left(lpUserName, InStr(1, lpUserName, Chr(0)) - 1)
UserName = lpUserName
DomainName = GetDomainFromRegistry()
End If

End Sub

How?
 
Giovanni,

As I see this I get the idea that you want to get the current user, by
instance in VBNet code.

Dim UserName as String = Environment.UserName

Is that what you want to get?

Cor
 
Giovanni pepe said:
I convert this code from VB6...
Problem : lResult =487

Private Declare Function w32_WNetGetUser Lib "mpr.dll" Alias
"WNetGetUserA"
(ByVal lpszLocalName As String, ByVal lpszUserName As String, ByVal
lpcchBuffer As Integer) As Integer


Public Sub GetCurrentLogon16(ByVal UserName As String, ByVal DomainName As
String)
Dim lpUserName As String
Dim lpnLength As Integer
Dim lResult As Integer
Dim lpDomain As String

lpUserName = New String(Chr(0), 256)
lResult = w32_WNetGetUser("", lpUserName, 256)

Try passing 'vbNullString' instead of "" in the first parameter.
Alternatively, you may want to use 'Environment.UserName' or
'SystemInformation.UserName' to get the current user name.
 
Back
Top