السلام عليكم ورحمة الله وبركاتة
ياريت حد يساعدنى فى طلبى
انا اريد تحويل هذا الكود من لغة الفجول بيسك الا لغة السى شارب لانى لا اجيد لغة الفجول بيسك ارجوكم المساعدة لانى محتاج الكود دة وهذا الكود هو كود معرفة السريل نمبر للفلاشة ميمورى
Imports System.Management
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fso As Object
Dim dc As Object
Dim d As Object
Dim xx, n As String
fso = CreateObject("Scripting.FileSystemObject")
dc = fso.Drives
For Each d In dc
If d.DriveType = 3 Then
n = d.ShareName
End If
Select Case d.DriveType
Case 1
xx = d.DriveLetter + ":\"
End Select
Next
Me.TextBox2.Text = GetSerialNumber(xx & ":")
End Sub
Public Function GetSerialNumber(ByVal DriveLetter As String) As String
DriveLetter = Mid$(DriveLetter, 1, 2)
If Mid$(DriveLetter, 2, 1) <> ":" Then Return ""
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='" & _
DriveLetter.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")
' There is a bug in WinVista that corrupts some of the fields
' of the Win32_DiskDrive class if you instantiate the class via
' its primary key (as in the example above) and the device is
' a USB disk. Oh well... so we have go thru this extra step
Dim wmi As New ManagementClass("Win32_DiskDrive")
' loop thru all of the instances. This is silly, we shouldn't
' 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
MessageBox.Show(DriveLetter & " doesn't appear to be USB Device", "Error")
Return ""
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
End Function
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox2.Text <> "4C532000061202103503" Then ' استبدل هذا الرقم برقم الفلاش ميموري الخاص بك
MsgBox("رقم الفلاش ميموري خاطئ") ' الكود الذي تريد تنفيذه اذا كان الرقم خاطئ
Else
MsgBox("رقم الفلاش ميموري صحيح") ' الكود الذي تريد تنفيذه اذا كان الرقم صحيح
End If
End Sub

