取得磁碟机之Volumn及Serial Number
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-03-19
适用Access97、2000 这两项磁碟机资料须使用API函数方可取得,代码如下: 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 Function GetVolumn(X As String) As String If Len(X) < 3 Then X = Left(X, 1) & ":\" Else X = Left(X, 3) End If Dim nRet As Long, VolName As String, VolSN As Long, MaxCompLen As Long Dim VolFlags As Long, VolFileSys As String VolName = Space$(256) VolFileSys = Space$(256) nRet = GetVolumeInformation(X, VolName, Len(VolName), _ VolSN, MaxCompLen, VolFlags, _ VolFileSys, Len(VolFileSys)) If nRet = 1 Then GetVolumn = VolName Else GetVolumn = "" End If End Function Function GetNumber(X As String) As String If Len(X) < 3 Then X = Left(X, 1) & ":\" Else X = Left(X, 3) End If Dim nRet As Long, VolName As String, VolSN As Long, MaxCompLen As Long Dim VolFlags As Long, VolFileSys As String VolName = Space$(256) VolFileSys = Space$(256) nRet = GetVolumeInformation(X, VolName, Len(VolName), _ VolSN, MaxCompLen, VolFlags, _ VolFileSys, Len(VolFileSys)) If nRet = 1 Then GetNumber = VolSN Else GetVolumn = "" End If End Function 前面的Declare陈述式宣告一个API函数(GetVolumeInformation),可取得磁碟机的两项资料。 |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
上一篇: Access数据库技术(49)下一篇: ASP+Access的安全隐患及对策
关于取得磁碟机之Volumn及Serial Number的所有评论