Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


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

PathCreateFromUrl (shlwapi)
 
.
Summary

C# Signature:

[DllImport("shlwapi.dll", SetLastError=true)]
static extern int PathCreateFromUrl([In]string url, [Out] StringBuilder path, [In,Out]ref uint pathLength, [In]uint reserved);
static extern TODO PathCreateFromUrl(TODO);

VB Signature:

    Declare Unicode Function PathCreateFromUrl Lib "shlwapi.dll" Alias "PathCreateFromUrlW" _
    (ByVal url As String, _
     ByVal path As System.Text.StringBuilder, _
     ByRef pathLength As System.UInt32, _
     ByVal reserved As Integer _
    ) As Integer

User-Defined Types:

None.

Alternative Managed API:

    Dim myUri As String = "file:///C|/Temp/foo.txt"
    Dim myResult As String = (new System.Uri(myUri)).LocalPath 'returns "C:\Temp\foo.txt"

Notes:

The pathLength will be at most MAX_PATH (defined in WinDef.h).

Do you know one? Please contribute it!

Returns an HRESULT.

Notes:

The pathLength will be at most MAX_PATH (defined in WinDef.h).

Tips & Tricks:

Please add some!

Returns an HRESULT.

Tips & Tricks:

Please add some!

Sample Code (VB winform):

    Const MAX_PATH As Integer = 260

    Private Sub pathFromUrlButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pathFromUrlButton.Click
      Dim sz As System.UInt32
      Dim sb As System.Text.StringBuilder
      Dim rc As Integer

      sz = Convert.ToUInt32(INTERNET_MAX_URL_LENGTH)
      sb = New System.Text.StringBuilder(INTERNET_MAX_URL_LENGTH)

      rc = PathCreateFromUrl(urlTextbox.Text, sb, sz, 0)

      pathTextbox.Text = sb.ToString()
    End Sub

Sample Code (VB winform):

    Const MAX_PATH As Integer = 260

    Private Sub pathFromUrlButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pathFromUrlButton.Click
      Dim sz As System.UInt32
      Dim sb As System.Text.StringBuilder
      Dim rc As Integer

      sz = Convert.ToUInt32(INTERNET_MAX_URL_LENGTH)
      sb = New System.Text.StringBuilder(INTERNET_MAX_URL_LENGTH)

      rc = PathCreateFromUrl(urlTextbox.Text, sb, sz, 0)

      pathTextbox.Text = sb.ToString()
    End Sub

Documentation

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 PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions