ShellUIHelper.AddFavorite method

Displays the default user interface for creating a favorite item. The user interface is initialized to the specified parameters.

Syntax

iRetVal = ShellUIHelper.AddFavorite(
  sURL,
  [ vTitle ]
)

Parameters

sURL [in]

Type: BSTR

A String value that specifies the URL of the item to be added to the Favorites folder.

vTitle [in, optional]

Type: Variant*

A Variant value that specifies the name of the item.

Examples

The following example shows the proper usage of this method for JScript embedded in HTML and Visual Basic.

JScript:

<html>
<head>
<title></title>

<object id="ShellUIHelper"
        classid="CLSID:64AB4BB7-111E-11d1-8F79-00C04FC2FBE1"
        width=0
        height=0
        VIEWASTEXT>
</object>

<script language="JavaScript">
    function fnShellUIHelperAddFavoriteJ()
    {
        ShellUIHelper.AddFavorite("https://www.msn.com", "MSN Home Page");
    }
</script>

</head>
<body onload=fnShellUIHelperAddFavoriteJ()>
</body>
</html>

Visual Basic:

Private Sub fnShellUIHelperAddFavoriteVB()
    Dim objShellUIHelper As ShellUIHelper
    
    Set objShellUIHelper = New ShellUIHelper
        objShellUIHelper.AddFavorite "https://www.msn.com", "MSN Home Page"
    Set objShellUIHelper = Nothing
End Sub

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional, Windows XP [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Exdisp.h
DLL
Shell32.dll (version 4.71 or later)