10-14-2011، 03:07 PM
با سورس زیر میتونید سریال درایو c رو بدست بیارید .
در زیر روش استفاده رو از تابع ذکر کردم
کد:
'Win32 API needed
Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
'Function to get the serial number
Public Function GetHDDSerial(ByVal drive As String) As String
Dim serial As Long
Dim str As String
'First get the serial number
serial = GetVolumeInformation(drive, vbNullString, 0, GetHDDSerial, ByVal 0&, ByVal 0&, vbNullString, 0)
'Convert the serial number to hexidecimal format
str = Hex$(serial)
'Add 0's (zeros) to the left
str = Right("00000000" & str, 8)
'Put a hyphen in the middle
str = Left$(str, 4) & "-" & Right$(str, 4)
'Return the value
GetHDDSerial = str
End Function
در زیر روش استفاده رو از تابع ذکر کردم
کد:
'Example usage
Label1.Caption = GetHDDSerial("C:\")
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg