FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Grupo de Trabajo
Posts: 1054
Joined: Sun Oct 09, 2005 10:41 PM
Grupo de Trabajo
Posted: Fri Feb 25, 2011 04:39 AM

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

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Grupo de Trabajo
Posted: Fri Feb 25, 2011 05:57 AM
Here is one of the ways to retrieve your PC's WorkGroup/Domain name
Code (fw): Select all Collapse
#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
Posts: 1054
Joined: Sun Oct 09, 2005 10:41 PM
Re: Grupo de Trabajo
Posted: Fri Feb 25, 2011 07:37 PM

Gracias,,, funciona perfectamente,....
Salu2

Continue the discussion