hn4u @ Last updated 21/11/04 22:42
Go to my homepage at http://4u.jcisio.com
Full version available at http://4u.jcisio.com/r/article398.htm

Không rõ

Lấy số xêri của đĩa

Hàm SerNum sau sẽ trả về số xêri (serial number) của đĩa. Bạn gọi như sau: SerNum(kí tự tên ổ đĩa). Kết quả là số thập phân, bạn hãy tự chuyển sang dạng thập lục phân.

Mã lệnh
Private Declare Function GetVolumeInformation& Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal pVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long)
Const MAX_FILENAME_LEN = 256

Public Function SerNum(Drive$) As Long
Dim No&, s As String * MAX_FILENAME_LEN
Call GetVolumeInformation(Drive + ":\", s, MAX_FILENAME_LEN, No, 0&, 0&, s, MAX_FILENAME_LEN)
SerNum = No
End Function

Trong hàm trên, giá trị trả về trong s là kiểu FAT của đĩa (logic).


hainam4u @ Last updated 21/11/04 22:42
Go to my homepage at http://4u.jcisio.com