PDA

View Full Version : [Q] Lấy ****** của ổ cứng..!



crazyman
05-06-2003, 10:55
Có ai biết cách lấy ****** của ổ cứng thì chỉ giúp mình với .. Mình đang cần!
Thanks

nguyenky
05-06-2003, 13:39
Bạn sử dụng GetVolumeInformation() trong API để lấy số series của đĩa cứng,
dưới đây là đoạn mã tôi viết cho VFOX đọc, bạn nghiêm cứu thêm biến thành VBasic :

FUNCTION HARDISK
PARAMETER tcRootpath
tcRootpath=ALLT(tcRootpath)
IF EMPTY(tcRootpath)
tcRootpath=SYS(5)
ELSE
IF LEN(tcRootpath)=1 OR LEN(tcRootpath)=2
tcRootpath=tcRootpath+IIF(LEN(tcRootpath)=1,':','' )
ELSE
RETURN ''
ENDIF
ENDIF
DECLARE GetVolumeInformation IN win32api STRING,STRING @,INTEGER ,INTEGER @,;
INTEGER @,INTEGER @,STRING @,INTEGER
lcName = SPACE(255)
lnNameLen = LEN(lcName)
lnSerialNumber = 0
lnFilenameMaxLength = 0
lnFileSystemFlags = 0
lcFileSystemName = SPACE(255)
lnFSNameLen = LEN(lcFileSystemName)

=GetVolumeInformation(tcRootpath,@lcName,lnNameLen ,@lnSerialNumber,;
@lnFilenameMaxLength,@lnFileSystemFlags,@lcFileSys temName,lnFSNameLen)

IF empty(lnSerialNumber)
RETURN ''
ELSE
if lnSerialNumber<=0
lnSerialNumber = (2^32) + lnSerialNumber
endif
lcSerial = transform(lnSerialNumber,"@0") &&chuyen so he 10 ve dang he 16
lcSerial = transform(substr(lcSerial,3),"@R ***X-***X")
RETURN lcSerial
ENDIF
ENDFUNC

crazyman
06-06-2003, 16:07
Thanks bạn nhiều!