vb.net获取机器号,vb如何获取电脑的机器码
VB.NET,部分机器获取不了CPU号(高分急用)
VB 我不熟,下面是用汇编写的,我运行过可以的。
我们提供的服务有:做网站、网站建设、微信公众号开发、网站优化、网站认证、孝昌ssl等。为上千企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的孝昌网站制作公司
//--------------------------------
.model small
.586
.stack
.code
idstring db 49 dup('$')
start:
mov ax,@code
mov ds,ax
lea di,idstring
mov eax,80000002h
cpuid
mov dword ptr [di],eax
mov dword ptr [di+4],ebx
mov dword ptr [di+8],ecx
mov dword ptr [di+12],edx
mov eax,80000003h
cpuid
mov dword ptr [di+16],eax
mov dword ptr [di+20],ebx
mov dword ptr [di+24],ecx
mov dword ptr [di+28],edx
mov eax,80000004h
cpuid
mov dword ptr [di+32],eax
mov dword ptr [di+36],ebx
mov dword ptr [di+40],ecx
mov dword ptr [di+44],edx
mov ah,09h
lea dx,idstring
int 21h
mov ah,4ch
int 21h
end start
//-------------------------------------------------------
程序确实可以执行,输出CPU的ID等信息。
注意:DOS下或MS-DOS下使用。
vb.net 获取局域网计算机的当前用户名和计算机型号等信息
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub GetName()
Dim sJM As String
Dim sMC As String
Dim sIP As String
Dim s As String
s = String(128, Chr(0))
GetComputerName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sJM = s'计算机名称
s = String(128, Chr(0))
GetUserName s, Len(s)
s = UCase(Left(s, InStr(1, s, Chr(0)) - 1))
sMC = s‘当前用户名称
End Sub
'用这种方法在远程获得再发回本机就可以吧
'取计算机型号暂时不会
VB获取电脑机器码
很难达到你的要求的,VB好像是获取不到硬盘的物理序列号的,只能获取到某一个分区的序列号.不过可以调用其它的程序写的获取硬盘物理序列号的dll来获取,CPU的序列号我用的是wmi.VB本来对底层方面就不是很好
引用api获得硬盘序列号
Private Declare Function MymachineC 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
Private Sub Form_Load()
Dim AA, 硬盘序列号, Maxlen, Sysflag As Long: Dim VolName, FsysName As String
AA = MymachineC("c:\", VolName, 256, 硬盘序列号, Maxlen, Sysflag, FsysName, 256)
msgbox "C硬盘序列号-机器码啦-(16制): " Hex(硬盘序列号)
End Sub
win7下vb.net 如何获取硬盘序列号
Private Function 硬盘序列号() As String
Try
Dim myInfo As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("HARDWARE\DEVICEMAP\Scsi\Scsi Port 0\Scsi Bus 1\Target Id 0\Logical Unit Id 0")
硬盘序列号 = Trim(myInfo.GetValue("SerialNumber"))
Catch
Try
Dim myInfo As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("HARDWARE\DEVICEMAP\Scsi\Scsi Port 1\Scsi Bus 1\Target Id 0\Logical Unit Id 0")
硬盘序列号 = Trim(myInfo.GetValue("SerialNumber"))
Catch
硬盘序列号 = ""
End Try
End Try
End Function
试下,如果返回为空,则表示失败。
在本机win8win8.1有效,不过好像在有些机器上没用。
VB如何获取机器码(硬盘码、主板码等)
'引用api获得硬盘序列号
Private Declare Function MymachineC 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
Private Sub Form_Load()
Dim AA, 硬盘序列号, Maxlen, Sysflag As Long: Dim VolName, FsysName As String
AA = MymachineC("c:\", VolName, 256, 硬盘序列号, Maxlen, Sysflag, FsysName, 256)
msgbox "C硬盘序列号-机器码啦-(16制): " Hex(硬盘序列号)
End Sub
这样就搞定了
文章标题:vb.net获取机器号,vb如何获取电脑的机器码
转载注明:http://myzitong.com/article/hsioej.html