0. 初始化环境和OLE对象
#include <utilcls.h> #include <shlobj.h> // 初始化COM环境 CoInitialize(NULL); // 创建Shell对象 Variant vShellOLE = Variant::CreateObject("Shell.Application");
1. 层叠窗口
Function CascadeWindows("CascadeWindows"); vShellOLE.Exec(CascadeWindows);
2. 横向平铺窗口
Function TileHorizontally("TileHorizontally"); vShellOLE.Exec(TileHorizontally);
3. 纵向平铺窗口
Function TileVertically("TileVertically"); vShellOLE.Exec(TileVertically);
4. 最小化所有窗口
Function MinimizeAll("MinimizeAll"); vShellOLE.Exec(MinimizeAll);
5. 撤消全部最小化
Function UndoMinimizeALL("UndoMinimizeALL"); vShellOLE.Exec(UndoMinimizeALL);
6. 设置时间
Function SetTime("SetTime"); vShellOLE.Exec(SetTime);
7. 查找计算机
Function FindComputer("FindComputer"); vShellOLE.Exec(FindComputer);
8. 查找文件
Function FindFiles("FindFiles"); vShellOLE.Exec(FindFiles);
9. 帮助
Function Help("Help"); vShellOLE.Exec(Help);
10. 运行文件
Function FileRun("FileRun"); vShellOLE.Exec(FileRun);
11. 任务栏属性
Function TrayProperties("TrayProperties"); vShellOLE.Exec(TrayProperties);
12. 挂起
Function Suspend("Suspend"); vShellOLE.Exec(Suspend);
13. 关闭Windows
Function ShutdownWindows("ShutdownWindows"); vShellOLE.Exec(ShutdownWindows);
14. 打开目录对话框
int SpecFolder[17] = { ssfDESKTOP, ssfPROGRAMS, ssfCONTROLS, ssfPRINTERS, ssfPERSONAL, ssfFAVORITES, ssfSTARTUP, ssfRECENT, ssfSENDTO, ssfBITBUCKET, ssfSTARTMENU, ssfDESKTOPDIRECTORY, ssfDRIVES, ssfNETWORK, ssfNETHOOD, ssfFONTS, ssfTEMPLATES }; Function BrowseForFolder("BrowseForFolder"); Variant ppsdf; int nIndex = 2; // 以选定的系统目录为根目录 ppsdf = vShellOLE.Exec(BrowseForFolder << short(Handle) << "BrowseForFolder method" << BIF_BROWSEINCLUDEFILES << Variant(SpecFolder[nIndex])); // 以指定的目录为根目录 String strPath("C:\\123"); ppsdf = vShellOLE.Exec(BrowseForFolder << short(Handle) << "BrowseForFolder method" << BIF_BROWSEINCLUDEFILES << Variant(strPath));
15. 浏览指定目录
int SpecFolder[17] = { ssfDESKTOP, ssfPROGRAMS, ssfCONTROLS, ssfPRINTERS, ssfPERSONAL, ssfFAVORITES, ssfSTARTUP, ssfRECENT, ssfSENDTO, ssfBITBUCKET, ssfSTARTMENU, ssfDESKTOPDIRECTORY, ssfDRIVES, ssfNETWORK, ssfNETHOOD, ssfFONTS, ssfTEMPLATES }; Function Explore("Explore"); // 浏览指定系统特殊目录 int nIndex = 2; vShellO
|