SHGetFolderPath (shell32)
Last changed: -24.39.41.252

.
Summary

C# Signature:

[DllImport("shell32.dll")]
static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken,
   uint dwFlags, [Out] StringBuilder pszPath);

VB.Net Signature:

    <DllImport("shell32.dll")> _
    Private Shared Function SHGetFolderPath(ByVal hwndOwner As IntPtr, ByVal nFolder As Int32, ByVal hToken As IntPtr, ByVal dwFlags As Int32, ByVal pszPath As StringBuilder) As Int32
    End Function

User-Defined Types:

    Private Const CSIDL_WINDOWS As Integer = &H24

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

    Dim winPath As New StringBuilder(300)
    If SHGetFolderPath(Nothing, CSIDL_WINDOWS, Nothing, 0, winPath) <> 0 Then
        Throw New ApplicationException("Can't get window's directory")
    End If
    Console.WriteLine(winPath.ToString)

Please add some!

Alternative Managed API:

Do you know one? Please contribute it!

Documentation