Grupo de Trabajo

Post Reply
User avatar
Willi Quintana
Posts: 1025
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú
Contact:

Grupo de Trabajo

Post by Willi Quintana »

Hola amigos:
NetName() nos devuelve el nombre de la PC, NetName(.t.) el nombre del usuario; alguna funcion para obtener el nombre del GRUPO DE TRABAJO ??
Salu2
User avatar
anserkk
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India
Has thanked: 2 times

Re: Grupo de Trabajo

Post by anserkk »

Here is one of the ways to retrieve your PC's WorkGroup/Domain name

Code: Select all | Expand


#Include "FiveWin.ch"
//-----------------------//
Function Main()

    Local oLoc,oWmi,oList,oItem

    oLoc:= CreateObject( "wbemScripting.SwbemLocator" )
    oWmi:= oLoc:ConnectServer()
   
    If oWmi == NIL
        ? "Sorry!! No Wmi"
        Return
    Endif
   
    oList := oWmi:ExecQuery("Select * from Win32_ComputerSystem")
   
    FOR EACH oItem IN oList
   
        cComputerDomain = oItem:Domain
        If oItem:PartOfDomain
            ? "Computer Domain: " + cComputerDomain
        Else
            ? "Workgroup: " + cComputerDomain
        EndIf    
   
    Next
   
Return NIL    


Please note :-

WMI is not available before Windows 2000 (unless it is installed separately).

Microsoft's document states that if the computer is not joined to a domain, the domain property of the Win32_ComputerSystem class is the name of the workgroup.

Regards
Anser
User avatar
Willi Quintana
Posts: 1025
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú
Contact:

Re: Grupo de Trabajo

Post by Willi Quintana »

Gracias,,, funciona perfectamente,....
Salu2
Post Reply