Trucco: Vb.Net rilevare il numero seriale del pc.
Tramite l'api GetVolumeInformation possiamo rilevare il numero seriale del pc.
Di seguito si riporta un frammento di codice:
'Namespace per la gestione delle api
Imports System.Runtime.InteropServices
'Dichiarazione api
<DllImport("kernel32.dll")> _
Friend Shared Function GetVolumeInformation(ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Integer, ByRef lpVolumeSerialNumber As Integer, ByRef lpMaximumComponentLength As Integer, ByRef lpFileSystemFlags As Integer, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Integer) As Boolean
End Function
'In una funzione o button.
Dim IntRes As Integer
Dim StrVolumeName As String = Space(255)
Dim StrFileSystemName As String = Space(255)
Dim IntSerialNum As Integer
IntRes = GetVolumeInformation("C:\", StrVolumeName, 255, IntSerialNum, 0, 0, StrFileSystemName, 255)
MsgBox(IntSerialNum)