Live Chat Icon For mobile
Live Chat Icon

How do I get the install directory for the version of the runtime that is loaded in the current process?

Platform: WinForms| Category: General

For example, the ‘C:\WINNT\Microsoft.NET\Framework\v1.0.3705’ dir for the 1.0 framework version.

You can do so using PInvoke to call this native API method:

// Declaration
internal static extern void GetCORSystemDirectory([MarshalAs(UnmanagedType.LPTStr)]System.Text.StringBuilder Buffer,
	int BufferLength, ref int Length);
// Gets the path to the Framework directory.
System.Text.StringBuilder sb = new System.Text.StringBuilder(1024);
int size;
// returned value in size can be ignored
GetCORSystemDirectory(sb, sb.Capacity, ref size);

’ Declaration
Private Declare Function GetCORSystemDirectory Lib 'mscoree.dll' ( ByVal Buffer As System.Text.StringBuilder, ByVal BufferLength As Integer, ByRef Length As Integer) As Integer

’ Gets the path to the Framework directory.
Dim Path As New System.Text.StringBuilder(1024)
Dim Size As Integer
’ returned value in Size can be ignored
GetCORSystemDirectory(Path, Path.Capacity, Size)

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.