Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting Network group INfo from a Win 95 pc
Message
De
19/05/1999 10:05:04
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Getting Network group INfo from a Win 95 pc
Divers
Thread ID:
00220420
Message ID:
00220420
Vues:
76
Compadres,

OK. We know to use the NetWkstaGetInfo in WIN32 API call in the MSDN
code below for VB. This works great on a NT Workstation pc.
But running this on a WIN95 pc (90% of our network) causes a
'function name not found in dll' error message. A similar call in FoxPro yields only the username.

OK. Here's th heart of the question: What API function or other FoxPro functions can be used to retrieve the lan group info for that pc user off of an NT 4.0 server?

Option Explicit
Private Type WKSTA_INFO_101
wki101_platform_id As Long
wki101_computername As Long
wki101_langroup As Long
wki101_ver_major As Long
wki101_ver_minor As Long
wki101_lanroot As Long
End Type

Private Type WKSTA_USER_INFO_1
wkui1_username As Long
wkui1_logon_domain As Long
wkui1_logon_server As Long
wkui1_oth_domains As Long
End Type

Private Declare Function WNetGetUser& Lib "Mpr" Alias "WNetGetUserA" _
(lpName As Any, ByVal lpUserName$, lpnLength&)
Private Declare Function NetWkstaGetInfo& Lib "Netapi32" _
(strServer As Any, ByVal lLevel&, pbBuffer As Any)
Private Declare Function NetWkstaUserGetInfo& Lib "Netapi32" _
(reserved As Any, ByVal lLevel&, pbBuffer As Any)
Private Declare Sub lstrcpyW Lib "Kernel32" (dest As Any, ByVal src As Any)
Private Declare Sub lstrcpy Lib "Kernel32" (dest As Any, ByVal src As Any)
Private Declare Sub RtlMoveMemory Lib "Kernel32" _
(dest As Any, src As Any, ByVal size&)
Private Declare Function NetApiBufferFree& Lib "Netapi32" (ByVal buffer&)

Function GetWorkstationInfo()
Dim ret As Long, buffer(512) As Byte, i As Integer
Dim wk101 As WKSTA_INFO_101, pwk101 As Long
Dim wk1 As WKSTA_USER_INFO_1, pwk1 As Long
Dim cbusername As Long, username As String
Dim computername As String, langroup As String, logondomain As _
String

' Clear all of the display values.
computername = "": langroup = "": username = "": logondomain = ""

' Windows 95 or NT - call WNetGetUser to get the name of the user.
username = Space(256)
cbusername = Len(username)
ret = WNetGetUser(ByVal 0&, username, cbusername)
If ret = 0 Then
' Success - strip off the null.
username = Left(username, InStr(username, Chr(0)) - 1)
Else
username = ""
End If

'================================================================
' The following section works only under Windows NT
'================================================================

'NT only - call NetWkstaGetInfo to get computer name and lan group
ret = NetWkstaGetInfo(ByVal 0&, 101, pwk101)
RtlMoveMemory wk101, ByVal pwk101, Len(wk101)
lstrcpyW buffer(0), wk101.wki101_computername
' Get every other byte from Unicode string.
i = 0
Do While buffer(i) <> 0
computername = computername & Chr(buffer(i))
i = i + 2
Loop
lstrcpyW buffer(0), wk101.wki101_langroup
i = 0
Do While buffer(i) <> 0
langroup = langroup & Chr(buffer(i))
i = i + 2
Loop
ret = NetApiBufferFree(pwk101)

' NT only - call NetWkstaUserGetInfo.
ret = NetWkstaUserGetInfo(ByVal 0&, 1, pwk1)
RtlMoveMemory wk1, ByVal pwk1, Len(wk1)
lstrcpyW buffer(0), wk1.wkui1_logon_domain
i = 0
Do While buffer(i) <> 0
logondomain = logondomain & Chr(buffer(i))
i = i + 2
Loop
ret = NetApiBufferFree(pwk1)

'================================================================
'End NT-specific section
'================================================================

Ed Hill, Quest Telecom, Atlanta, edhill@bellsouth.net

Debug.Print computername, langroup, username, logondomain
End Function
Répondre
Fil
Voir

Click here to load this message in the networking platform