Creating and Cracking URLs
The InternetCreateUrl function uses the data in the URL_COMPONENTS structure to create a URL.
The components that make up the URL_COMPONENTS structure are the scheme, host name, port number, user name, password, URL path, and additional data, such as search parameters. Each component, except the port number, has a string member that holds the data, and a member that holds the length of the string member.
For each required component, the pointer member should contain the address of the buffer holding the data. The length member should be set to zero if the pointer member contains the address of a zero-terminated string; the length member should be set to the string length if the pointer member contains the address of a string that is not zero-terminated. The pointer member of any components that are not required must be set to NULL.
The InternetCrackUrl function separates a URL into its component parts and returns the components indicated by the URL_COMPONENTS structure passed to the function. The scheme and port numbers have only a member that stores the corresponding value; they are both returned on all successful calls to InternetCrackUrl.
To get the value of a particular component in URL_COMPONENTS, the member that stores the string length of that component must be set to a nonzero value. The string member can be either the address of a buffer or NULL.
If the pointer member contains the address of a buffer, the string length member must contain the size of that buffer. InternetCrackUrl returns the component data as a string in the buffer and stores the string length in the string length member.
If the pointer member is set to NULL, the string length member can be set to any nonzero value. InternetCrackUrl stores the address of the first character of the URL string that contains the component data and sets the string length to the number of characters in the remaining part of the URL string that pertains to the component.
All pointer members set to NULL with a nonzero length member point to the appropriate starting point in the URL string. The length stored in the length member must be used to determine the end of the individual component's data.
To finish initializing URL_COMPONENTS properly, the dwStructSize member must be set to the size of the URL_COMPONENTS structure.
See Also
Last updated on Wednesday, April 13, 2005
© 2005 Microsoft Corporation. All rights reserved.