Méthode IShellDispatch3.AddToRecent

Ajoute un fichier à la liste la plus récente utilisée (MRU).

Syntaxe

IShellDispatch3.AddToRecent(
  varFile,
  [ bstrCategory ]
)

IShellDispatch3.AddToRecent( _
  ByVal varFile As Variant, _
  [ ByVal bstrCategory As BSTR ] _
)

Paramètres

varFile [in]

Type : Variant

Chaîne qui contient le chemin d’accès du fichier à ajouter à la liste des documents récemment utilisés.

Windows Vista : définissez ce paramètre sur null pour effacer le dossier de documents récents.

bstrCategory [in, facultatif]

Type : BSTR

Chaîne qui contient le nom de la catégorie dans laquelle placer le fichier.

Valeur retournée

JScript

Cette méthode ne retourne pas de valeur.

VB

Cette méthode ne retourne pas de valeur.

Exemples

Les exemples suivants montrent l’utilisation de AddToRecent pour JScript, VBScript et Visual Basic.

Jscript:

<script language="JScript">
    function fnIShellDispatch3AddToRecentJ()
    {
        var objShell = new ActiveXObject("shell.application");
        var ssfWINDOWS = 36;
        var objFolder;
        
        objFolder = objShell.NameSpace(ssfWINDOWS);
        if (objFolder != null)
        {
            var objFolderItem;
            
            objFolderItem = objFolder.ParseName("system.ini");
            if (objFolderItem != null)
            {
                objShell.AddToRecent(objFolderItem.Path);
            }
        }
    }
</script>

Vbscript:

<script language="VBScript">
     function fnIShellDispatch3AddToRecentVB()
        dim objShell
        
        set objShell = CreateObject("shell.application")
        if (not objShell is nothing) then
            dim objFolder
            dim ssfWINDOWS
            
            ssfWINDOWS = 36
            set objFolder = objShell.NameSpace(ssfWINDOWS)
            if (not objFolder is nothing) then
                dim objFolderItem
                        
                set objFolderItem = objFolder.ParseName("system.ini")
                if (not objFolderItem is nothing) then
                    objShell.AddToRecent (objFolderItem.Path)
                end if
                set objFolderItem = nothing
            end if
            set objFolder = nothing
        end if
        set objShell = nothing
    end function
 </script>

Visual Basic :

Private Sub fnIShellDispatch3AddToRecent()
    Dim objShell  As Shell
    Dim objFolder As Folder
    Dim ssfWINDOWS As Long

    ssfWINDOWS = 36
    Set objShell = New Shell
    Set objFolder = objShell.NameSpace(ssfWINDOWS)
    If (Not objFolder Is Nothing) Then
        Dim objFolderItem As FolderItem

        Set objFolderItem = objFolder.ParseName("system.ini")
        If (Not objFolderItem Is Nothing) Then
            objShell.AddToRecent (objFolderItem.Path)
        End If
        Set objFolderItem = Nothing
    End If
    Set objFolder = Nothing
    Set objShell = Nothing
End Sub

Spécifications

Condition requise Valeur
Client minimal pris en charge
Windows XP [applications de bureau uniquement]
Serveur minimal pris en charge
Windows Server 2003 [applications de bureau uniquement]
En-tête
Shldisp.h
IDL
Shldisp.idl
DLL
Shell32.dll (version 6.0 ou ultérieure)