快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

包含vb.netusb设备的词条

VB.NET检测插入U盘时执行某段代码,并能获取U盘盘符

以下内容为网络提供,但我自己验证可行,供你参考.

平原ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:028-86922220(备注:SSL证书合作)期待与您的合作!

Imports System.IO

Public Class Form1

Public Const WM_DEVICECHANGE = H219

Public Const DBT_DEVICEARRIVAL = H8000

Public Const DBT_CONFIGCHANGECANCELED = H19

Public Const DBT_CONFIGCHANGED = H18

Public Const DBT_CUSTOMEVENT = H8006

Public Const DBT_DEVICEQUERYREMOVE = H8001

Public Const DBT_DEVICEQUERYREMOVEFAILED = H8002

Public Const DBT_DEVICEREMOVECOMPLETE = H8004

Public Const DBT_DEVICEREMOVEPENDING = H8003

Public Const DBT_DEVICETYPESPECIFIC = H8005

Public Const DBT_DEVNODES_CHANGED = H7

Public Const DBT_QUERYCHANGECONFIG = H17

Public Const DBT_USERDEFINED = HFFFF

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)

If m.Msg = WM_DEVICECHANGE Then

Select Case m.WParam

Case WM_DEVICECHANGE

Case DBT_DEVICEARRIVAL 'U盘插入

ComboBox1.Items.Clear()

Dim s() As DriveInfo = DriveInfo.GetDrives

For Each drive As DriveInfo In s

If drive.DriveType = DriveType.Removable Then

ListBox1.Items.Add("U盘已插入!盘符为:" + drive.Name.ToString())

ComboBox1.Items.Add(drive.Name)

End If

Next

BtnWrite.Enabled = True

BtnRead.Enabled = True

Case DBT_CONFIGCHANGECANCELED

Case DBT_CONFIGCHANGED

Case DBT_CUSTOMEVENT

Case DBT_DEVICEQUERYREMOVE

Case DBT_DEVICEQUERYREMOVEFAILED

Case DBT_DEVICEREMOVECOMPLETE 'U盘卸载

ListBox1.Items.Add("U盘卸载!")

BtnWrite.Enabled = False

BtnRead.Enabled = False

Case DBT_DEVICEREMOVEPENDING

Case DBT_DEVICETYPESPECIFIC

Case DBT_DEVNODES_CHANGED

Case DBT_QUERYCHANGECONFIG

Case DBT_USERDEFINED

End Select

End If

MyBase.WndProc(m)

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

ListBox1.Items.Add("请您现在插入U盘至USB接口!")

End Sub

Private Sub BtnWrite_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnWrite.Click

If ComboBox1.Text = "" Then

MsgBox("请选择U盘盘符!", MsgBoxStyle.Exclamation, "Warn")

Else

Dim Writer As StreamWriter = Nothing

Try

Dim fileName As String = ComboBox1.Text + "Test.txt"

Writer = New StreamWriter(fileName)

Writer.WriteLine(InputBox("老四,请输入要保存的字符串", "输入信息", "Input then Test String! hehe!"))

MsgBox("Write to " + fileName + " Success!")

Catch ex As Exception

MsgBox(ex.Message, MsgBoxStyle.Critical, "Write 失败")

Finally

If Writer IsNot Nothing Then Writer.Close()

End Try

End If

End Sub

Private Sub BtnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnRead.Click

If ComboBox1.Text = "" Then

MsgBox("请选择U盘盘符!", MsgBoxStyle.Exclamation, "Warn")

Else

Dim Reader As StreamReader = Nothing

Try

Dim fileName As String = ComboBox1.Text + "Test.txt"

Reader = New StreamReader(fileName)

MsgBox("Read from " + fileName + vbCrLf + Reader.ReadToEnd, MsgBoxStyle.Information, "Info")

Catch ex As Exception

MsgBox(ex.Message, MsgBoxStyle.Critical, "Read 失败")

Finally

If Reader IsNot Nothing Then Reader.Close()

End Try

End If

End Sub

End Class

用VB如何实现已有USB视频设备的数据采集?

上有capture.ocx控件,可以捕捉连接在电脑上的各种摄像设备。

只要在vb里把这个控件导入即可,当把控件放到form上以后捕捉即开始了,超级简单。

可操作的功能也都被封装成了属性和方法,用起来与其它控件没什么差别。

如果不想依赖外部ocx,还可以选择调用Win API函数,不过相当麻烦,最好还是下载这个capture.ocx

VB.NET怎样把USB摄像头在显示器上输出的实时画面(像素信息),引入到数据库.

用directshow获取帧缓存,转换为标准图像格式(比如jpg,png这些),存储到数据库的image字段里就行了.

如何用vb编写一个程序可以禁用或者启用usb存储设备

你可以在设备管理里面 将光电鼠用的那个USB以外的所有USB禁用 就可以了

如果不希望别人修改 你可以让普通用户成为非管理员权限

当然也可以在BIOS里面,在“Integrated Peripherals”选项下,将“USB 1.1 Controller”和“USB 2.0 Contr01ler”选项的属性设置为“Disableed”。就可以了


分享文章:包含vb.netusb设备的词条
链接URL:http://6mz.cn/article/heopjo.html

其他资讯