掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
ドライブの状態を確認し続けるには (ID:144893)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
こんな感じかな。 Imports System.Runtime.InteropServices Public Class Form1 Protected Overrides Sub WndProc(ByRef m As Message) If m.Msg = &H219 Then If m.WParam = New IntPtr(&H8000) Then Dim drives() As String = GetDrives(m.LParam) If drives.Length > 0 Then ListBox1.Items.Add(Join(drives) & "が追加されました。") End If ElseIf m.WParam = New IntPtr(&H8004) Then Dim drives() As String = GetDrives(m.LParam) If drives.Length > 0 Then ListBox1.Items.Add(Join(drives) & "が削除されました。") End If End If End If MyBase.WndProc(m) End Sub Private Shared Function GetDrives(ByVal p As IntPtr) As String() If Marshal.ReadInt32(p, 4) <> &H2 OrElse Marshal.ReadInt16(p, 16) = &H1 Then Return New String() {} End If Dim list As New List(Of String)() Dim unitmask As Integer = Marshal.ReadInt32(p, 12) For i As Integer = 0 To 25 If (unitmask And 1) = 1 Then list.Add(Chr(i + Asc("A")) & ":") End If unitmask >>= 1 Next Return list.ToArray() End Function End Class
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.