Ciao,
sai se esiste qualche funzione similare a nserialhd() che mi da un identificazione unica di u HD o di un una Pendrive Usb ?
Poiche' nserialhd() varia ogni volta che formatto l'unità
Romeo/zingoni
Moderator: Enrico Maria Giordano
Romeo wrote:Ciao,
sai se esiste qualche funzione similare a nserialhd() che mi da un identificazione unica di u HD o di un una Pendrive Usb ?
Poiche' nserialhd() varia ogni volta che formatto l'unità
Romeo/zingoni
/* ***********************************************************************
A partir d'una lletra d'un USB inicia la cerca del seu número de sèrie.
-------------------------------------------------------------------- */
STATIC FUNCTION GetUSBSerial( cDrive )
Local oLoc := CreateObject( "wbemScripting.SwbemLocator" )
Local oSrv := oLoc:ConnectServer()
Local oJobs := oSrv:ExecQuery( "SELECT * FROM Win32_LogicalDiskToPartition" )
Local oJob
Local cDriveNumber
cDrive = Upper( cDrive )
If Len( cDrive ) == 1
cDrive += ":"
Endif
If Len( cDrive ) > 2
cDrive = SubStr( cDrive, 1, 2 )
Endif
For each oJob in oJobs
If cDrive == StrToken( oJob:Dependent, 2, '"' )
cDriveNumber = SubStr( StrToken( StrToken( oJob:Antecedent, 2, '"' ), 1, "," ), 7 )
return GetSerial( oSrv, cDriveNumber )
Endif
Next
Return "."
/* *************************** */
/* *************************** */
/* *********************************************************
Cerca a partir d'una lletra d'USB el seu número de sèrie.
------------------------------------------------------ */
STATIC FUNCTION GetSerial( oSrv, cDriveNumber )
Local aDrives := oSrv:ExecQuery( "SELECT * FROM Win32_DiskDrive" )
Local oDrive, cSerial := ""
For each oDrive in aDrives
If oDrive:Name == "\\.\PHYSICALDRIVE" + cDriveNumber .and. ;
oDrive:InterfaceType == "USB"
cSerial = oDrive:PNPDeviceID
cSerial = SubStr( cSerial, 1, RAt( "&", cSerial ) - 1 )
cSerial = SubStr( cSerial, RAt( "&", cSerial ) + 1 )
If At( "\", cSerial ) != 0
cSerial = SubStr( cSerial, At( "\", cSerial ) + 1 )
Endif
Return cSerial
//Exit
Endif
Next
Return cSerial
/* *************************** */
Romeo wrote:many thanks !
Can also you help me to set a serial in USBdrive ?
example:
setserialusb("G:","123456789") ?
tks
Romeo
Return to All products support
Users browsing this forum: No registered users and 14 guests