| - WMI Fun !! -|WMI Step|WMI Sample|Search|WMI Fun !! Groups|About WMI Fun !! | ||||||
| Top Page >> WMI Step >> ディスクのパーティション情報を取得する | ||||||
|
ディスクのパーティション情報を取得する
■Topicsハードディスクドライブのパーティション情報を取得するサンプルです。Win32_DiskPartitionクラスを使用します。 Private Sub Command1_Click()
Dim DiskSet As SWbemObjectSet
Dim Disk As SWbemObject
Dim Locator As SWbemLocator
Dim Service As SWbemServices
Dim MesStr As String
Set Locator = New WbemScripting.SWbemLocator
Set Service = Locator.ConnectServer
Set DiskSet = Service.ExecQuery("Select * From Win32_DiskPartition")
For Each Disk In DiskSet
MesStr = MesStr & vbCrLf & _
"パーティション名:" & Disk.Name & vbCrLf & _
"パーティションサイズ:" & Disk.Size & vbCrLf & _
"ブートパーティション:" & Disk.BootPartition & vbCrLf & _
"プライマリパーティション:" & Disk.PrimaryPartition & vbCrLf
Next
MsgBox "ディスクのパーティション情報です。" & _
vbCrLf & MesStr & vbCrLf & "ですよ。"
Set DiskSet = Nothing
Set Disk = Nothing
Set Locator = Nothing
Set Service = Nothing
End Sub
実行すると各パーティションごとにサイズ・ブートパーティション・プライマリーパーティションを表示します。
WMI を本で勉強したい方へ。
なかなか WMI のことが乗っている書籍は少ないですが…管理系業務に係る方には楽しめるかも? |
|
| ^ | Copyright(C) 1997-2008 とお All rights reserved. | << |