Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SHGetFolderPath (shell32)

C# Signature:

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

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

Alternative Managed API:

Do you know one? Please contribute it!


Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Find References
Show Printable Version