Método Shell.AddToRecent

Adiciona um arquivo à lista mru (usada mais recentemente).

Sintaxe

Shell.AddToRecent(
  varFile,
  [ bstrCategory ]
)

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

Parâmetros

varFile [in]

Tipo: Variant

Uma Cadeia de Caracteres que contém o caminho do arquivo a ser adicionado à lista de documentos usados recentemente.

Windows Vista: defina esse parâmetro como nulo para limpar a pasta de documentos recentes.

bstrCategory [in, opcional]

Tipo: BSTR

Uma Cadeia de Caracteres que contém o nome da categoria na qual colocar o arquivo.

Valor retornado

JScript

Esse método não retorna um valor.

VB

Esse método não retorna um valor.

Exemplos

Os exemplos a seguir mostram o uso de AddToRecent para JScript, VBScript e 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

Requisitos

Requisito Valor
Cliente mínimo com suporte
Windows XP [somente aplicativos da área de trabalho]
Servidor mínimo com suporte
Windows Server 2003 [somente aplicativos da área de trabalho]
Cabeçalho
Shldisp.h
IDL
Shldisp.idl
DLL
Shell32.dll (versão 6.0 ou posterior)