.NET 4.x Конвертировать с Delphi на VB.NET. Код определения флешки - Visual Basic .NET
Формулировка задачи:
Всем доброго времени суток!
Знатоки! Помогите конвертировать этот код написанный на DELPHI в Vb.net...ну, пожалуйста. Мне, собственно, нужно узнать вставлена флешка или нет.Решение задачи: «.NET 4.x Конвертировать с Delphi на VB.NET. Код определения флешки»
textual
Листинг программы
Public Class Form1 Public Delegate Sub dHookSub(ByVal msg As System.Windows.Forms.Message) Private Const DBT As Int32 = &H219 '537 Private Const DBT_Device_Arrival As Int32 = &H8000 Private Const DBT_Device_Remove_Complete = &H8004 Public Structure sPMSG Public d As dHookSub Public Msg As Int32 Public Sub New(ByVal d As dHookSub, Msg As Int32) Me.d = d Me.Msg = Msg End Sub End Structure Private Class cWinMessages Inherits NativeWindow Public checks As List(Of sPMSG) = Nothing Public Sub New(ByVal Parent As Form) Me.checks = New List(Of sPMSG) AddHandler Parent.HandleCreated, AddressOf Me.OnHandleCreated AddHandler Parent.HandleDestroyed, AddressOf Me.OnHandleDestroyed If Me.Handle <> Parent.Handle Then AssignHandle(CType(Parent, Form).Handle) End Sub Private Sub OnHandleCreated(ByVal sender As Object, ByVal e As EventArgs) AssignHandle(CType(sender, Form).Handle) End Sub Private Sub OnHandleDestroyed(ByVal sender As Object, ByVal e As EventArgs) ReleaseHandle() End Sub Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) MyBase.WndProc(m) Dim Msg As Int32 = m.Msg For i As Int32 = Me.checks.Count - 1 To 0 Step -1 If (Me.checks(i).Msg = Msg) Then Me.checks(i).d(m) Next End Sub End Class Private wm As cWinMessages = Nothing Private Sub Flash(ByVal m As System.Windows.Forms.Message) Dim WParam As Int32 = m.WParam.ToInt32 If WParam = DBT_Device_Arrival Then MsgBox("Добавили флешку", MsgBoxStyle.Information) If WParam = DBT_Device_Remove_Complete Then MsgBox("Вынули флешку", MsgBoxStyle.Information) End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.Show() Me.wm = New cWinMessages(Me) Me.wm.checks.Add(New sPMSG(AddressOf Me.Flash, DBT)) End Sub End Class
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д