IShellDispatch3.AddToRecent 方法
將檔案新增至最近使用的 (MRU) 清單。
語法
IShellDispatch3.AddToRecent(
varFile,
[ bstrCategory ]
)
IShellDispatch3.AddToRecent( _
ByVal varFile As Variant, _
[ ByVal bstrCategory As BSTR ] _
)
參數
-
varFile [in]
-
類型: Variant
String,其中包含要新增至最近使用檔案清單的檔案路徑。
Windows Vista:將此參數設定為 null ,以清除最近的檔資料夾。
-
bstrCategory [in, optional]
-
類型: BSTR
String,其中包含要放置檔案之類別的名稱。
傳回值
JScript
這個方法不會傳回值。
VB
這個方法不會傳回值。
範例
下列範例示範如何使用 AddToRecent for 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 |
|