w32_WNetGetUser not work Win98

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?
 
K

Ken Tucker [MVP]

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?
 
C

Cor Ligthert

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
 
H

Herfried K. Wagner [MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top