28-05-19, 01:53 AM
(آخر تعديل لهذه المشاركة : 28-05-19, 01:54 AM {2} بواسطة asemshahen5.)
هذا كود جلب سيريال الفلاشة :
PHP كود :
Public Shared Function GetSerialNumber1(ByVal Num As Integer) As String
Try
FlashName.Clear()
For Each drv In My.Computer.FileSystem.Drives
If drv.DriveType = IO.DriveType.Removable Then
FlashName.Add(drv.Name)
End If
Next
Dim wmi_ld, wmi_dp, wmi_dd As ManagementObject
Dim temp, parts(), ans As String
ans = ""
'get the Logical Disk for that drive letter'
wmi_ld = New ManagementObject("Win32_LogicalDisk.DeviceID='" & FlashName(Num).ToString.TrimEnd("\"c) & "'")'
'get the associated DiskPartition '
For Each wmi_dp In wmi_ld.GetRelated("Win32_DiskPartition")
'get the associated DiskDrive'
For Each wmi_dd In wmi_dp.GetRelated("Win32_DiskDrive")
'a USB disk. Oh well... so we have go thru this extra step'
Dim wmi As New ManagementClass("Win32_DiskDrive")
'have to loop thru them all, when we know which one we want.'
For Each obj As ManagementObject In wmi.GetInstances
'Do the DeviceID fields match?'
If obj("DeviceID").ToString = wmi_dd("DeviceID").ToString Then
'The serial number is embedded in the PnPDeviceID'
temp = obj("PnPDeviceID").ToString
If Not temp.StartsWith("USBSTOR") Then
Throw New ApplicationException(FlashName(Num).ToString & " doesn't appear to be USB Device")
End If
parts = temp.Split("\&".ToCharArray)
'The serial number should be the next to the last element'
ans = parts(parts.Length - 2)
End If
Next
Next
Next
Return ans
Catch ex As Exception
MsgBox("Error : " & ex.Message, MsgBoxStyle.Critical, "Error")
Return Nothing
End Try
End Function
سبحان الله وبحمده سبحان الله العظيم و الحمد لله ولا اله الا الله والله اكبر
