CWebView::GetHomeUrl Method  
 
INT GetHomeUrl(
  LPTSTR lpszHomeUrl,  
  INT nMaxLength,  
);
INT GetHomeUrl(
  CString& strHomeUrl  
);

The GetHomeUrl method returns the current home URL for the browser instance.

Parameters

lpszHomeUrl
A null-terminated string buffer which will contain the home URL string for the browser session. If this parameter is NULL, the string will not be copied and the function will return the length of the string, not including the terminating null character. An alternate version of this method accepts a reference to a CString object which will contain the home URL when the method returns.
nMaxLength
An integer which specifies the maximum number of characters which can be copied into the string buffer. If the lpszHomeUrl parameter is NULL, this value should be zero.

Return Value

If the method succeeds, the return value is the number of characters in the home URL, not including the terminating null character. If a home URL has not been specified, or the method fails, the return value is zero. To get extended error information, call the GetLastError method.

Remarks

The GetHomeUrl method retrieves the home URL associated with the specified WebView control. If no home URL has been defined, the method returns zero and the output buffer is empty.

When an instance of the browser is first created, no default home URL is assigned. In particular, the home URL is not automatically initialized to about:blank or to the address of the first document loaded. The application must explicitly assign a home URL using SetHomeUrl. Until a home URL has been assigned, this method returns zero.

The length returned by this method does not include the terminating null character. If the output buffer is NULL or the maximum buffer length is zero, the method returns the number of characters required to store the URL, excluding the terminating null character. This allows an application to determine the required buffer size before retrieving the URL.

If the supplied buffer is too small to contain the complete URL and its terminating null character, the method fails and sets the last error to ST_ERROR_BUFFER_TOO_SMALL. The URL is never truncated. The maximum buffer length is specified in characters for Unicode applications and bytes for applications using UTF-8 encoding.

Retrieving the home URL does not change the current document or navigation state of the browser.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib
Unicode: Implemented as Unicode and ANSI versions

See Also