Windowsフォルダの場所を取得する
メモ:Windowsフォルダは標準ではWindows95/98/Me/XPは「C:\Windows」、Windows NT/2000では「C:\Winnt」です。けれども、ドライブを変更するなど標準ではない設定でインストールする場合がありますから下記の 方法でWindowsフォルダの場所を取得する必要があります。
Dim Path As String
Path = Environ("WINDIR")
MsgBox Path
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Const MAX_PATH As Integer = 260Private Sub Command1_Click() Dim Path As String
Path = WindowsFolder()
MsgBox Path
End Sub
Private Function WindowsFolder() As String Dim FolderName As String
FolderName = Space(MAX_PATH)
Call GetWindowsDirectory(FolderName, Len(FolderName))
WindowsFolder = Left(FolderName, InStr(1, FolderName, vbNullChar) - 1)End Function
VB.NET2002以降では「Windowsフォルダの場所を取得する」を参照