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
nserialhd()
Moderator: Enrico Maria Giordano
Re: nserialhd()
Quizás te sirva.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
Code: Select all
/* ***********************************************************************
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
/* *************************** */
Un Saludo
Carlos G.
FiveWin 19.06 + Harbour 3.2, BCC 7 Windows 10
Carlos G.
FiveWin 19.06 + Harbour 3.2, BCC 7 Windows 10
Re: nserialhd()
many thanks !
Can also you help me to set a serial in USBdrive ?
example:
setserialusb("G:","123456789") ?
tks
Romeo
Can also you help me to set a serial in USBdrive ?
example:
setserialusb("G:","123456789") ?
tks
Romeo
Re: nserialhd()
I think is not posible.Romeo wrote:many thanks !
Can also you help me to set a serial in USBdrive ?
example:
setserialusb("G:","123456789") ?
tks
Romeo
Un Saludo
Carlos G.
FiveWin 19.06 + Harbour 3.2, BCC 7 Windows 10
Carlos G.
FiveWin 19.06 + Harbour 3.2, BCC 7 Windows 10
Re: nserialhd()
tks any