ヘッダー

VB.NET 2002, VB.NET 2003, VB2005

.NET Frameworkのインストールパスを取得する

以下の関数CLRPathを使用すると、.NET Frameworkのインストールされているパスを取得することができる。

メモ:.NET Frameworkがインスストールされているパスはたとえば、「C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\」です。

VB.NET2002対応 VB.NET2003対応 VB2005対応

Imports System.Runtime.InteropServices

Private Declare Function GetCORSystemDirectory Lib "mscoree.dll" ( _
<MarshalAs(UnmanagedType.LPWStr)> ByVal Buffer As System.Text.StringBuilder, _
ByVal BufferLength As Integer, _
ByRef Length As Integer _
) As
Integer

Public Shared Function CLRPath() As String

    Dim SB As New System.Text.StringBuilder(1024)
    Dim Size As
Integer

    GetCORSystemDirectory(SB, SB.Capacity, Size)

    Return SB.ToString

End Function

 


VB6対応 VB6でもGetCORSystemDirectory関数を使うことにより同様のことが実現可能なはずです。また、VBランタイムのインストールパスの取得方法は未詳です。