|
Private Sub Workbook_Open()
On Error Resume Next
1:
Set fs = CreateObject("Scripting.FileSystemObject")
DrivesCount = fs.drives.Count
' Set d = fs.GetDrive(Chr(66 + DrivesCount))'U盘时用
Set d = fs.GetDrive("D:")
dt = d.drivetype
sn = d.serialnumber
If dt <> 2 Then
' If dt <> 1 Then 'U盘时用
msg = MsgBox("系统检测无密钥盘,单击是,插入密钥盘重试,单击否,退出程序", vbYesNo, "提示")
If msg = vbYes Then
GoTo 1
Else
ThisWorkbook.Close False
Exit Sub
End If
Else
If sn = 1955786478 Then '密钥盘序列号
Exit Sub
Else
MsgBox "找不到密钥盘,系统将退出。"
ThisWorkbook.Close False
End If
End If
End Sub
用这个可以通过硬盘的分区或U盘来加密。那如果用硬盘的硬盘物理序列号(唯一)进行加密,请教应如何设置代码?
链接:获取硬盘物理系列号http://club.excelhome.net/viewth ... p;page=1#pid2875800
[ 本帖最后由 joen168 于 2009-6-16 17:12 编辑 ] |
|