Page 1 of 1

How To Identify A Computer

PostPosted: Mon May 27, 2013 12:03 am
by acwoo1
Hi

I think Netname() is not unique. Is there a way to identify a computer ?

Thanks

Regards
ACWoo
FHW1304+bcc582+Harbour

Re: How To Identify A Computer

PostPosted: Mon May 27, 2013 12:21 am
by pablovidal
Code: Select all  Expand view
//-----------------------------------------------------------
Static Function SerialProtect()
//-----------------------------------------------------------
local oLoc := CreateObject( "wbemScripting.SwbemLocator" )
local oSrv := oLoc:ConnectServer(,"root\cimv2")
local aDrives := oSrv:ExecQuery( "SELECT * FROM Win32_ComputerSystemProduct" )
local oDrive, cSerial := ""
Local aData  := {}

 for each oDrive in aDrives
  AADD( aData, oDrive:UUID )
 Next

 For nAt := 1 to Len( aData )
  cSerial += Upper( AllTrim( cStr( aData[nAt] ) ) )
 Next nAt

Return( cSerial )

Re: How To Identify A Computer

PostPosted: Mon May 27, 2013 12:24 am
by ADutheil
You can use MAC address.

Code: Select all  Expand view

FUNCTION MacAddress
LOCAL oLoc
LOCAL oSrv
LOCAL oNics
LOCAL oTemp
LOCAL aMacs := {}
 
oLoc := CREATEOBJECT( "wbemScripting.SwbemLocator" )
oSrv := oLoc:ConnectServer()
oNics := oSrv:ExecQuery( "SELECT * FROM Win32_NetworkAdapter WHERE ConfigManagerErrorCode = 0" )
FOR EACH oTemp IN oNics
    IF !empty( oTemp:MACAddress )
        AADD( aMacs, oTemp:MACAddress )
    ENDIF
NEXT
RETURN if( !empty( aMacs ), aMacs[ 1 ], transform( HB_Random() * 1000000000000, "99:99:99:99:99:99" ) )