當任務欄裏沒有「顯示桌面圖標」時 可在記事本中寫:javascript
[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktopjava
備註:保存成.scf 格式shell
javascript:
<script language="JScript">
function fnIShellDispatch4ToggleDesktopJ()
{
var objShell = new ActiveXObject("shell.application");
objShell.ToggleDesktop();
}
</script>windows
VBScript:
<script language="VBScript">
function fnIShellDispatch4ToggleDesktopVB()
dim objShell
set objShell = CreateObject("shell.application")
objShell.ToggleDesktop
set objShell = nothing
end function
</script>app
Visual Basic:
Private Sub fnIShellDispatch4ToggleDesktopVB()
Dim objShell As Shell
Set objShell = New Shell
objShell.ToggleDesktop
Set objShell = Nothing
End Sub測試
C++實現顯示桌面:ui
/*
程序: 顯示桌面 C++ 實現
說明: IShellDispatch4 接口只有WINDOWS XP以上的操做系統才支持,須要 shell32.dll 5.0或以上版本
編譯環境: Microsoft Visual Studio 2008
*/
#include <windows.h>
#include <shldisp.h>url
int main()
{
CoInitialize(0);
IShellDispatch4 * pdisp=NULL;
CoCreateInstance(CLSID_Shell,NULL,CLSCTX_ALL,__uuidof(IShellDispatch4),(void **)&pdisp);
pdisp->ToggleDesktop();
pdisp->Release();
CoUninitialize();
return 0;
}spa
C#實現顯示桌面: 在vs2003中沒有反應,在vs2005中可行,已測試操作系統
/*
* 程序 : 顯示桌面 C# 實現
* 編譯環境 : Microsoft Visual Studio 2008
*/
using System;
using System.Reflection;
namespace CSCONSOLE
{
class Program
{
public static void Main(string [] args)
{
Type oleType=Type.GetTypeFromProgID("Shell.Application");
object oleObject=System.Activator.CreateInstance(oleType);
oleType.InvokeMember("ToggleDesktop",BindingFlags.InvokeMethod,null,oleObject,null);
}
}
}
SCF文件是「WINDOWS資源管理器命令」文件,它也是一種可執行文件.
該類型文件由Windows Explorer Command解釋,標準安裝,包括下面3個該類型的文件
===========================
1) Explorer.scf(資源管理器)
[Shell]
Command=2
IconFile=explorer.exe,1
[Taskbar]
Command=Explorer
===========================
2)Show Desktop.scf(顯示桌面)
格式相似以下:
[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop
===========================
3)View Channels.scf(查看頻道)
[Shell]
Command=3
IconFile=shdocvw.dll,-118
建立桌面快捷方式
<script language="javascript">
var url = "C:\\Documents and Settings\\Administrator.WBT-E231DA542FA\\Application Data\\Microsoft\\Internet Explorer\\Quick Launch\\顯示桌面.scf";
var lnk = "桌面快捷方式";
var fso = new ActiveXObject("Scripting.FileSystemObject");
var shell = new ActiveXObject("WScript.Shell");
var DesktopPath = shell.SpecialFolders("Desktop");
if(!fso.FolderExists(DesktopPath))
{
fso.CreateFolder(tagFolder); */
//fso.CreateFolder(DesktopPath);
}
if(!fso.FileExists(DesktopPath + "\\"+lnk+".lnk"))
{
var link = shell.CreateShortcut(DesktopPath + "\\"+lnk+ ".lnk");
link.Description = "用JS生成客戶端快捷方式";
link.TargetPath = url;
link.WindowStyle = 1;
link.Save();
}
</script>
System.Diagnostics.Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL");// 控制面板 System.Diagnostics.Process.Start("explorer.exe", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}");// 個人電腦 System.Diagnostics.Process.Start("explorer.exe", "::{645FF040-5081-101B-9F08-00AA002F954E}");// 回收站 System.Diagnostics.Process.Start("explorer.exe", "::{208D2C60-3AEA-1069-A2D7-08002B30309D}");// 網上鄰居 System.Diagnostics.Process.Start("rundll32.exe", "devmgr.dll DeviceManager_Execute");// 設備管理器 System.Diagnostics.Process.Start("rundll32.exe", "shell32.dll,Control_RunDLL timedate.cpl");//日期和時間