在Windows资源管理器中,进入到“系统盘:\WINDOWS\inf”目录,找到名为“Usbstor.pnf”的文件,右键点击该文件,在弹出菜单中选择“属性”,然后切换到“安全”标签页,在“组或用户名称”框中选中要禁止的用户组 , 接着在用户组的权限框中,选中“完全控制”后面的“拒绝”复选框,最后点击“确定”按钮 。
再使用以上方法,找到“usbstor.inf”文件并在安全标签页中设置为拒绝该组的用户访问,其操作过程同上 。完成了以上设置后 , 该组中的用户就无法安装USB设备驱动程序了,这样就达到禁用的目的 。
注意:要想使用访问控制列表(ACL),要采用NTFS文件系统 。
上面有一些是用修改注册表来实现的,你用VB访问注册表来修改就可以实现
(锁定光驱在Win2000上的实现)
新建一个工程,在窗体上加入两个按钮,粘贴以下程序,看看效果怎么样?^_^
Option Explicit
Private Const GENERIC_READ As Long = H80000000
Private Const FILE_SHARE_READ As Long = H1
Private Const FILE_SHARE_WRITE As Long = H2
Private Const OPEN_EXISTING As Long = 3
Private Const IOCTL_STORAGE_MEDIA_REMOVAL As Long = H2D4804
Private Type PREVENT_MEDIA_REMOVAL
PreventMediaRemoval As Byte
End Type
Private Declare Function DeviceIoControl Lib "kernel32" (ByVal hDevice As Long, ByVal dwIoControlCode As Long, lpInBuffer As Any, ByVal nInBufferSize As Long, lpOutBuffer As Any, ByVal nOutBufferSize As Long, lpBytesReturned As Long, lpOverlapped As Any) As Long
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, lpSecurityAttributes As Any, ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Function LockCDROM(szDrive As String, IsLock As Boolean) As Boolean
On Error GoTo Err
Dim hDevice As Long
Dim PMR As PREVENT_MEDIA_REMOVAL
Dim bytesReturned As Long
Dim Success As Long
hDevice = CreateFile("\\.\"szDrive, GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, ByVal 0, OPEN_EXISTING, 0, 0)
PMR.PreventMediaRemoval = CByte(Abs(IsLock))
Success = DeviceIoControl(hDevice, IOCTL_STORAGE_MEDIA_REMOVAL, PMR, Len(PMR), ByVal 0, 0, bytesReturned, ByVal 0)
【vb.net弹出光驱 vbs弹出光驱】CloseHandle hDevice
LockCDROM = True
Exit Function
Err:
LockCDROM = False
End Function
Private Sub Command1_Click()
Dim ret As Boolean
ret = LockCDROM("H:", True)'我的光驱盘符是H:
If ret Then
MsgBox "锁定成功", vbInformation, "提示"
Else
MsgBox "锁定失败", vbInformation, "提示"
End If
End Sub
Private Sub Command2_Click()
Dim ret As Boolean
ret = LockCDROM("H:", False)
If ret Then
MsgBox "解除锁定成功", vbInformation, "提示"
Else
MsgBox "解除锁定失败", vbInformation, "提示"
End If
End Sub
VB.net怎么定期弹出主窗口?首先要添加两个窗体,假设第一个窗体名为Form1,第二个窗体名为Form2 。在Form1窗体中添加个按钮Command1 。按钮单击事件的代码为:
Private Sub Command1_Click()
Form2.Show '用show方法加载并且显示名为Form2的窗体
End Sub
show 方法后面省略了两个参数即Form2.Show 0或Form2.Show 1此参数可缺省 。可自行运行验证
VB.net怎么弹出如下类似的对话框(看图)?可以利用msgbox 实现,也可以通过另外的窗体上画出表格实现
方法一,利用msgbox:
Private Sub Command1_Click()Dim a As Long, b As Long, c As LongMsgBox "┌────┬────┬────┐"vbCrLf _"│库存1 │库存2 │库存3 │"vbCrLf _"├────┼────┼────┤"vbCrLf _"│"formatstr(a)"│"formatstr(b)"│"formatstr(c)"│"vbCrLf _"└────┴────┴────┘"End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j)inputStrSpace(j)Space((8 - Len(inputStr)) Mod 2)End Function
推荐阅读
- mysql事务效率如何,mysql事务有什么作用
- python如何输出列表的大小,python中怎么输出列表
- 乐游下载,乐游下载手机版
- c语言插入时间桩函数 c语言时间相加的程序
- 现在采用鸿蒙系统的手机,现在鸿蒙系统的手机有哪些
- flutter的布局,flutter 常用布局
- 钉钉高峰期没法开直播,钉钉高峰期没法开直播吗
- gorust语言 go语言ui
- linux命令怎么关机,linux怎么关机操作