Skip to content

Latest commit

 

History

History
146 lines (114 loc) · 4.14 KB

nf-shlwapi-parseurlw.md

File metadata and controls

146 lines (114 loc) · 4.14 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:shlwapi.ParseURLW
ParseURLW function (shlwapi.h)
Performs rudimentary parsing of a URL. (Unicode)
ParseURL
ParseURL function [Windows Shell]
ParseURLW
_win32_ParseURL
shell.ParseURL
shlwapi/ParseURL
shlwapi/ParseURLW
shell\ParseURL.htm
shell
3d42dad0-b9eb-4e40-afc8-68cb85b27504
12/05/2018
ParseURL, ParseURL function [Windows Shell], ParseURLA, ParseURLW, _win32_ParseURL, shell.ParseURL, shlwapi/ParseURL, shlwapi/ParseURLA, shlwapi/ParseURLW
shlwapi.h
Windows
Windows Vista [desktop apps only]
Windows Server 2003 [desktop apps only]
ParseURLW (Unicode) and ParseURLA (ANSI)
Shlwapi.dll (version 6.0.1 or later)
Windows
19H1
ParseURLW
shlwapi/ParseURLW
c++
APIRef
kbSyntax
DllExport
Shlwapi.dll
API-MS-Win-Core-url-l1-1-0.dll
KernelBase.dll
API-MS-Win-DownLevel-shlwapi-l1-1-0.dll
API-MS-Win-DownLevel-shlwapi-l1-1-1.dll
ParseURL
ParseURLA
ParseURLW

ParseURLW function

-description

Performs rudimentary parsing of a URL.

-parameters

-param pcszURL [in]

Type: LPCTSTR

A pointer to a null-terminated string containing the URL to be parsed.

-param ppu [in, out]

Type: PARSEDURL*

A pointer to a PARSEDURL structure that receives the parsed results. The calling application must set the structure's cbSize member to the size of the structure before calling ParseURL.

-returns

Type: HRESULT

Returns S_OK on success, or a COM error code otherwise. The function returns URL_E_INVALID_SYNTAX (defined in Intshcut.h) if the string could not be parsed as a URL.

-remarks

The parsing performed by ParseURL is fairly rudimentary. For more sophisticated URL parsing, use InternetCrackUrl.

Examples

This sample console application uses ParseURL to parse several simple URLs.

#include <windows.h>
#include <shlwapi.h>
#include <stdio.h>
#include <tchar.h>

void sample(LPCTSTR pcszUrl)
{
    PARSEDURL pu;
    pu.cbSize = sizeof(pu);
    HRESULT hr = ParseURL(pcszUrl, &pu);
    _tprintf(TEXT("ParseURL(%s) returned 0x%08x\n"), pcszUrl, hr);
    if (SUCCEEDED(hr)) {
        _tprintf(TEXT("Protocol = %.*s\n"), pu.cchProtocol, pu.pszProtocol);
        _tprintf(TEXT("Suffix   = %.*s\n"), pu.cchSuffix, pu.pszSuffix);
        _tprintf(TEXT("Scheme   = %d\n"), pu.nScheme);
        _tprintf(TEXT("\n"));
    }
}

int __cdecl main()
{
    sample(TEXT("http://msdn.microsoft.com/vstudio/"));
    sample(TEXT("mailto:someone@example.com"));
    sample(TEXT("file://C:\\AUTOEXEC.BAT"));
    sample(TEXT("C:\\AUTOEXEC.BAT"));
    return 0;
}   

Output:

ParseURL(http://msdn.microsoft.com/vstudio/) returned 0x00000000
Protocol = http
Suffix   = //msdn.microsoft.com/vstudio/
Scheme   = 2

ParseURL(mailto:someone@example.com) returned 0x00000000
Protocol = mailto
Suffix   = someone@example.com
Scheme   = 4

ParseURL(file://C:\AUTOEXEC.BAT) returned 0x00000000
Protocol = file
Suffix   = C:\AUTOEXEC.BAT
Scheme   = 9

ParseURL(C:\AUTOEXEC.BAT) returned 0x80041001

Note

The shlwapi.h header defines ParseURL as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.