怎么样在VB里得到当前盘c:的序列号

wang7655 2003-10-20 02:08:38
怎么样在VB里得到当前盘c:的序列号

因为,每个硬盘里格式化一次,序列号变换一次,几乎没有重复的

怎么样才可以得到呢?
...全文
77 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
yijiansong 2003-10-22
  • 打赏
  • 举报
回复
up
suntt 2003-10-22
  • 打赏
  • 举报
回复
我接着此题问一下,怎么修改呀?
注:用编码的方式(vb,vc,asm等等)
CBASE 2003-10-22
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
Label1.Caption = GetSerialNumber(Text1.Text + ":\")


End Sub

Private Sub form_load()


'使用该函数:





'它将告诉磁盘序号。

End Sub
CBASE 2003-10-22
  • 打赏
  • 举报
回复
Private Declare Function GetVolumeInformation Lib _
"kernel32.dll" Alias "GetVolumeInformationA" (ByVal _
lpRootPathName As String, ByVal lpVolumeNameBuffer As _
String, ByVal nVolumeNameSize As Integer, _
lpVolumeSerialNumber As Long, lpMaximumComponentLength _
As Long, lpFileSystemFlags As Long, ByVal _
lpFileSystemNameBuffer As String, ByVal _
nFileSystemNameSize As Long) As Long



'代码如下:



Function GetSerialNumber(strDrive As String) As Long

Dim SerialNum As Long

Dim Res As Long

Dim Temp1 As String

Dim Temp2 As String

Temp1 = String$(255, Chr$(0))

Temp2 = String$(255, Chr$(0))

Res = GetVolumeInformation(strDrive, Temp1, _
Len(Temp1), SerialNum, 0, 0, Temp2, Len(Temp2))

GetSerialNumber = SerialNum

End Function
christensen 2003-10-21
  • 打赏
  • 举报
回复
Public Declare Function GetVolumeInformation 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


Global GetVal As Long
Global GetVal2 As Long
Private Sub Form_Load()
Dim TempStr1 As String * 256

Dim TempStr2 As String * 256

Dim TempLon1 As Long

Dim TempLon2 As Long

Call GetVolumeInformation("C:\", TempStr1, 256, GetVal, TempLon1, TempLon2, TempStr2, 256)


Text1.Text = GetVal '提取本机C盘的序列号至文本框一


End Sub
bigpig 2003-10-21
  • 打赏
  • 举报
回复
up
zz124 2003-10-21
  • 打赏
  • 举报
回复
Up!
flc 2003-10-21
  • 打赏
  • 举报
回复
学习
rainstormmaster 2003-10-21
  • 打赏
  • 举报
回复
up
online 2003-10-21
  • 打赏
  • 举报
回复
Option Explicit

Private Sub Form_Load()
'使用fso对象
Dim fso As filesystemobject
Dim drv As Drive
Dim infostr As String

Set fso = New filesystemobject
Set drv = fso.getdrive(fso.getdrivename("c:"))

infostr = "driver" & UCase("c:") & vbCrLf
infostr = infostr & "序列号:" & drv.serialnumber & vbCrLf
MsgBox infostr
End Sub
Micro_Sheng 2003-10-20
  • 打赏
  • 举报
回复
'把以下代码加入模块中,直接调用GetSerial()即可得到相应序列号

Private Declare Function GetVolumeInformation 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

Public Function GetSerial() As String
Dim rel As Long

Dim VolName As String '磁盘名称
Dim fsysName As String '磁盘格式
Dim VolSerial As Long '磁盘序列号
Dim Sysflag As Long
Dim Maxlen As Long

VolName = String(256, 0)
fsysName = String(256, 0)

rel = GetVolumeInformation("c:\", VolName, 256, VolSerial, Maxlen, Sysflag, fsysName, 256)


GetSerial = Hex(VolSerial)

End Function
lihonggen0 2003-10-20
  • 打赏
  • 举报
回复
硬盘序列号
http://vip.6to23.com/NowCan1/tech/vb_hd_info.htm
http://vip.6to23.com/NowCan1/code/hd_info.zip
www.jiaxinda.com/dont_delete/98及2K取硬盘id号_类.exe
lihonggen0 2003-10-20
  • 打赏
  • 举报
回复
Private Declare Function GetVolumeInformation 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 Serial As Long, VName As String, FSName As String
'Create buffers
VName = String$(255, Chr$(0))
FSName = String$(255, Chr$(0))
'Get the volume information
GetVolumeInformation "C:\", VName, 255, Serial, 0, 0, FSName, 255
'Strip the extra chr$(0)'s
VName = Left$(VName, InStr(1, VName, Chr$(0)) - 1)
FSName = Left$(FSName, InStr(1, FSName, Chr$(0)) - 1)
MsgBox "The Volume name of C:\ is '" + VName + "', the File system name of C:\ is '" + FSName + "' and the serial number of C:\ is '" + Trim(Str$(Serial)) + "'", vbInformation + vbOKOnly, App.Title
End Sub

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧