كيف أعمل ذلك باستخدام هذا الكود ..... ؟.
التصريحات
Private Const MAX_FILENAME_LEN = 256
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)
main function
Public Function GetSerialNumber(sDrive As String) As Long
Dim ser As Long
Dim s As String * MAX_FILENAME_LEN
Dim s2 As String * MAX_FILENAME_LEN
Dim i As Long
Dim j As Long
Call GetVolumeInformation(sDrive + ":" & Chr$(0), s, MAX_FILENAME_LEN, ser, i, j, s2, MAX_FILENAME_LEN)
GetSerialNumber = ser
End Function
example
MsgBox GetSerialNumber("c")