Menuへ
フォルダが空か調べる



シートのコード

Option Explicit

'フォルダが空か調べる
'戻り値
'空の場合: 1
'空でなければ: 0
Private Declare Function PathIsDirectoryEmpty Lib "SHLWAPI.DLL" Alias "PathIsDirectoryEmptyA" (ByVal pszPath As String) As Boolean

Private Sub CommandButton1_Click()
    'フォルダが空か調べる
    If PathIsDirectoryEmpty("C:\test\") = 1 Then
        CommandButton1.Caption = "空"
    Else
        CommandButton1.Caption = "有り"
    End If
End Sub

Private Sub CommandButton2_Click()
    'フォルダが空か調べる
    If PathIsDirectoryEmpty("C:\windows\") = 1 Then
        CommandButton2.Caption = "空"
    Else
        CommandButton2.Caption = "有り"
    End If
End Sub



Topへ