How To Identify A Computer

How To Identify A Computer

Postby acwoo1 » Mon May 27, 2013 12:03 am

Hi

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

Thanks

Regards
ACWoo
FHW1304+bcc582+Harbour
acwoo1
 
Posts: 161
Joined: Tue Nov 10, 2009 10:56 am

Re: How To Identify A Computer

Postby pablovidal » Mon May 27, 2013 12:21 am

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 )
Saludos,

Pablo Alberto Vidal
/*
------------------------------------------------------
Harbour 3.2.0, Fivewin 17.02, BCC7
------------------------------------------------------
*/
User avatar
pablovidal
 
Posts: 401
Joined: Thu Oct 06, 2005 10:15 pm
Location: Republica Dominicana

Re: How To Identify A Computer

Postby ADutheil » Mon May 27, 2013 12:24 am

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" ) )
 
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 107 guests