10-02-17, 03:24 PM
(29-09-16, 11:34 PM)ابراهيم النعيمي كتب : ممكن ذلك عن طريق الدالة التالية:بارك الله فيك وجزاك الله خيرا
كود :
' getting harddrive Serial NO
Function Gettingharddriveid() As String
Dim x As String = ""
Try
Dim hd As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
For Each dvs As ManagementObject In hd.Get()
x = dvs("SerialNumber").ToString()
Exit For
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
Gettingharddriveid = x
End Function
نتيجة هذه الدالة هو الرقم المتسلسل للهارد دسك
و بالامكان استخدام الرقم المتسلسل للمذر بورد كالتالي:
كود :
' getting Mother Board Serial NO
Function GettingMotherBoardID() As String
Dim x As String = ""
Dim oConn As ConnectionOptions = New ConnectionOptions
Dim oMs As System.Management.ManagementScope = New System.Management.ManagementScope("\\machineID")
Dim oQuery As System.Management.ObjectQuery = New System.Management.ObjectQuery("select SerialNumber from Win32_BaseBoard")
Dim oSearcher As ManagementObjectSearcher = New ManagementObjectSearcher(oMs, oQuery)
Dim oReturnCollection As ManagementObjectCollection = oSearcher.Get
For Each oReturn As ManagementObject In oReturnCollection
x = oReturn("SerialNumber").ToString
Next
GettingMotherBoardID = x
End Function
كما انه بالامكان استخدام الرقم المتسلسل للمعالج كما يأتي:
كود :
' getting processor Serial NO
Function Gettingprocessorid() As String
Dim x As String = ""
Dim win32MgmtClass As System.Management.ManagementClass
win32MgmtClass = New System.Management.ManagementClass("Win32_Processor")
Dim processors As System.Management.ManagementObjectCollection
processors = win32MgmtClass.GetInstances()
For Each processor As System.Management.ManagementObject In processors
x = processor("ProcessorID").ToString()
Next
Gettingprocessorid = x
End Function
بقي ان انبه الى انه يجب استيراد النطاق التالي :
كود :
Imports System.Management
ارجو ان يكون الشرح وافيا
تحياتي.

