- WMI Fun !! -|WMI StepWMI SampleSearchWMI Fun !! GroupsAbout WMI Fun !!
Top Page >> WMI Step >> ファイルの作成日時/更新日時を取得する
ファイルの作成日時/更新日時を取得する
Topics

ファイルの作成日時/更新日時を取得するサンプルです。CIM_DataFileクラスを使用します。


Sample Code

Private Sub Command1_Click()

Dim CdfSet As SWbemObjectSet
Dim Cdf As SWbemObject
Dim Locator As SWbemLocator
Dim Service As SWbemServices
Dim MesStr As String

Set Locator = New WbemScripting.SWbemLocator
Set Service = Locator.ConnectServer
Set CdfSet = Service.ExecQuery("Select * From CIM_DataFile Where Name = 'c:\\boot.ini'")

For Each Cdf In CdfSet
    
    MesStr = "ファイル名:" & Cdf.Name & vbCrLf & _
            "作成日時:" & Cdf.InstallDate & vbCrLf & _
            "更新日時:" & Cdf.LastModified & vbCrLf & _
            "アクセス日時:" & Cdf.LastAccessed & vbCrLf

Next

MsgBox "ファイルの作成日/更新日です。" & vbCrLf & _
            vbCrLf & MesStr & vbCrLf & "ですよ。"

Set CdfSet = Nothing
Set Cdf = Nothing
Set Service = Nothing
Set Locator = Nothing

End Sub

Comment

実行するとcドライブにある、boot.iniファイルを検索して作成日時、更新日時、アクセス日時を表示します。


WMI を本で勉強したい方へ。 Windows PowerShellインアクション を読んでみては?
なかなか WMI のことが乗っている書籍は少ないですが…管理系業務に係る方には楽しめるかも?
パソコンで目が疲れたら、ブルーベリーアイ
『ブルーベリーアイ』1粒中ビルベリーエキス160mg【楽天シニア市場】
 ^ Copyright(C) 1997-2008 とお All rights reserved. <<