WMI Fun !! 〜 WMI に興味がある方・システム管理者必見! 〜 |
|
![]() |
WMI Fun !! > WMI Sample (VB) > ファイルの作成日時、更新日時を取得する |
ファイルの作成日時、更新日時を取得する: CIM_DataFile - WMI Sample (VB)Topics
ファイルの作成日時、更新日時を取得するサンプルプログラムです。
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 ファイルを検索して作成日時、更新日時、アクセス日時を表示します。
![]() Recommended book
個人的にお勧めする本の紹介です。 ![]() |
ご意見・ご要望・ご感想をこちらのアンケートからお待ちしています |
∧ ページの先頭へ… |