戻る

Windows フォルダのパスを取得
動作環境 Windows98/2000 開発環境 Visual Basic 6.0 (+SP5)
説明 FileSystemObject オブジェクトの GetSpecialFolder メソッドを利用して、Windows フォルダのパスを取得します。
用意するもの:標準フォーム(Form1)、コマンドボタン (Command1)


Private Sub Command1_Click()

Dim MyFSO As Object
Dim MyFolder As String
Const WindowsFolder = 0

Set MyFSO = CreateObject("Scripting.FileSystemObject")

MyFolder = MyFSO.GetSpecialFolder(WindowsFolder)

MsgBox MyFolder, vbInformation, "Windows フォルダのパスを取得"

Set MyFSO = Nothing

End Sub