IShellDispatch3.AddToRecent 方法
将文件添加到最近使用的 (MRU) 列表中。
语法
IShellDispatch3.AddToRecent(
varFile,
[ bstrCategory ]
)
IShellDispatch3.AddToRecent( _
ByVal varFile As Variant, _
[ ByVal bstrCategory As BSTR ] _
)
参数
-
varFile [in]
-
类型: Variant
包含要添加到最近使用的文档列表的文件路径的 字符串 。
Windows Vista:将此参数设置为 null 以清除“最近使用的文档”文件夹。
-
bstrCategory [in, optional]
-
类型: BSTR
一个 字符串 ,其中包含要在其中放置文件的类别的名称。
返回值
JScript
此方法不返回值。
VB
此方法不返回值。
示例
以下示例演示如何将 AddToRecent 用于 JScript、VBScript 和 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
要求
要求 | 值 |
---|---|
最低受支持的客户端 |
Windows XP [仅限桌面应用] |
最低受支持的服务器 |
Windows Server 2003 [仅限桌面应用] |
标头 |
|
IDL |
|
DLL |
|