Resumen Usuario de red   (2 mensajes )


He encontrado esto que quizas pueda ayudaros.

It can be useful to obtain the login name of the user currently logged in
to the Windows for Workgroups system. This code should help a little:

Declare Function WNetGetUser Lib "wfwnet.drv" (ByVal szUser As String,
nBufferSize As Integer) As Integer

Declare Function MNetNetworkEnum Lib "wfwnet.drv" (lphNetwork As Integer)
As Integer

Declare Function MNetSetNextTarget Lib "wfwnet.drv" (ByVal hNetwork As
Integer) As Integer

Sub Form_Load ()
    Dim User As String
    If Not MultiNetGetUser(User) Then
       Label1.Caption = "Not logged on."
    Else
       Label1.Caption = "Logged on as " + User
    End If
End Sub

Function MultiNetGetUser (UserName$) As Integer
' The following function determines the logged-in user in Windows for
' Workgroups:
   Dim hNetDrv As Integer
   Dim wRetEnum As Integer, ret As Integer
   Dim wRetGetUser As Integer
   Dim cb As Integer
   Dim Found As Integer

   Found = False
   ' Grab the 1st network:
   hNetDrv = 0
   wRetEnum = MNetNetworkEnum(hNetDrv)
   ' Loop while there are installed networks:
   While (wRetEnum = 0) And Not Found
      User$ = Space$(255)
      cb = Len(User$)
      ' Make sure correct network is accessed in next WNetGetUser call:
      ret = MNetSetNextTarget(hNetDrv)
      ' Get the user:
      wRetGetUser = WNetGetUser(User$, cb)
      ' Check for success:
      If wRetGetUser = 0 Then
         ' Just grab the relevant characters:
         UserName$ = Left$(User$, cb - 1)
         Found = True
      End If
      ' Get the next network:
       wRetEnum = MNetNetworkEnum(hNetDrv)
   Wend
   MultiNetGetUser = Found
End Function
_________________________________________________
José Rubí de la Vega
E-mail : jrubi@arrakis.es
WWW : http://www.arrakis.es/~jrubi

 _________________ ______ _____
 ______ /___ __ \____ _____ /_ ___(_)
 ___ _ / __ /_/ /_ / / /__ __ \__ /
 / /_/ / _ _, _/ / /_/ / _ /_/ /_ /
 \____/ /_/ |_| \__,_/ /_.___/ /_/


Hola amigos,

Leo, prueba con esto ... a mi me funciona muy bien con Win95 y NT4

Debes poner la declaración en un módulo.

-----------------------------
Private Declare Function GetUserName Lib "advapi32.dll" Alias _
  "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function GetMyUserName()
  Dim sName As String
  Dim lNameLen As Long
  Dim lReturn As Long
  lNameLen = 255
  sName = Space(256)
  lReturn = GetUserName(sName, lNameLen)
  If sName = "" Then
    GetMyUserName = "(Desconocido)"
  Else
    GetMyUserName = Left(sName, InStr(sName, Chr(0)) - 1)
  End If
End Function
--------------

Saludos a todos,

Alberto.

----------
> From: Leonardo Schurjin <Schurjin@Iname.com>
> To: vb-esp@ccc.uba.ar
> Subject: (VB-ESP) Sobre UserID..
> Date: Friday, August 22, 1997 6:40 PM
>
> Hola todo el mundo.
>
> Espero que esten bien. Yo ando aqui, molestandolos nuevamente.
>
> Necesito obtener el nombre del usuario del login de windows, ya sea en
> su version win 3.1,3.11 y win 95.
>
> Agradeceria una respuesta de como se hace, o de algun link a lagun
> ejemplo en la web.
>
> Muchos saludos
>
> Leo.



Resumen Resumen

Visual Basic Página de Visual Basic

Página principal Página principal

www.jrubi.com