百度空间 | 百度首页 
 
查看文章
 
[UMU WSH 教程](13)常见对象 - Shell.Application
2007年04月16日 星期一 10:38

[UMU WSH 教程](11)常见对象 - FSO

[UMU WSH 教程](12)常见对象 - InternetExplorer.Application


  Shell.Application 对象由 Shell32.dll 提供,这次用更专业的 OleView 查看,可以获得这个对象有以下接口函数(省略 IDispatch 接口函数):

[id(0x60020000), propget, helpstring("Get Application object")]
HRESULT Application( [out, retval] IDispatch** ppid );

[id(0x60020001), propget, helpstring("Get Parent object")]
HRESULT Parent( [out, retval] IDispatch** ppid );

[id(0x60020002), helpstring("Get special folder from ShellSpecialFolderConstants")]
HRESULT NameSpace(
          [in] VARIANT vDir,
          [out, retval] Folder** ppsdf);

[id(0x60020003), helpstring("Browse the name space for a Folder")]
HRESULT BrowseForFolder(
          [in] long Hwnd,
          [in] BSTR Title,
          [in] long Options,
          [in, optional] VARIANT RootFolder,
          [out, retval] Folder** ppsdf);

[id(0x60020004), helpstring("The collection of open folder windows")]
HRESULT Windows( [out, retval] IDispatch** ppid );

[id(0x60020005), helpstring("Open a folder")]
HRESULT Open( [in] VARIANT vDir );

[id(0x60020006), helpstring("Explore a folder")]
HRESULT Explore( [in] VARIANT vDir );

[id(0x60020007), helpstring("Minimize all windows")]
HRESULT MinimizeAll();

[id(0x60020008), helpstring("Undo Minimize All")]
HRESULT UndoMinimizeALL();

[id(0x60020009), helpstring("Bring up the file run")]
HRESULT FileRun();

[id(0x6002000a), helpstring("Cascade Windows")]
HRESULT CascadeWindows();

[id(0x6002000b), helpstring("Tile windows vertically")]
HRESULT TileVertically();

[id(0x6002000c), helpstring("Tile windows horizontally")]
HRESULT TileHorizontally();

[id(0x6002000d), helpstring("Exit Windows")]
HRESULT ShutdownWindows();

[id(0x6002000e), helpstring("Suspend the pc")]
HRESULT Suspend();

[id(0x6002000f), helpstring("Eject the pc")]
HRESULT EjectPC();

[id(0x60020010), helpstring("Bring up the Set time dialog")]
HRESULT SetTime();

[id(0x60020011), helpstring("Handle Tray properties")]
HRESULT TrayProperties();

[id(0x60020012), helpstring("Display shell help")]
HRESULT Help();

[id(0x60020013), helpstring("Find Files")]
HRESULT FindFiles();

[id(0x60020014), helpstring("Find a computer")]
HRESULT FindComputer();

[id(0x60020015), helpstring("Refresh the menu")]
HRESULT RefreshMenu();

[id(0x60020016), helpstring("Run a Control Panel Item")]
HRESULT ControlPanelItem( [in] BSTR szDir );

[id(0x60030000), helpstring("get restriction settings")]
HRESULT IsRestricted(
          [in] BSTR Group,
          [in] BSTR Restriction,
          [out, retval] long* plRestrictValue);

[id(0x60030001), helpstring("Execute generic command")]
HRESULT ShellExecute(
          [in] BSTR File,
          [in, optional] VARIANT vArgs,
          [in, optional] VARIANT vDir,
          [in, optional] VARIANT vOperation,
          [in, optional] VARIANT vShow);

[id(0x60030002), helpstring("Find a Printer in the Directory Service")]
HRESULT FindPrinter(
          [in, optional] BSTR Name,
          [in, optional] BSTR location,
          [in, optional] BSTR model);

[id(0x60030003), helpstring("Retrieve info about the user's system")]
HRESULT GetSystemInformation(
          [in] BSTR Name,
          [out, retval] VARIANT* pv);

[id(0x60030004), helpstring("Start a service by name, and optionally set it to autostart.")]
HRESULT ServiceStart(
          [in] BSTR ServiceName,
          [in] VARIANT Persistent,
          [out, retval] VARIANT* pSuccess);

[id(0x60030005), helpstring("Stop a service by name, and optionally disable autostart.")]
HRESULT ServiceStop(
          [in] BSTR ServiceName,
          [in] VARIANT Persistent,
          [out, retval] VARIANT* pSuccess);

[id(0x60030006), helpstring("Determine if a service is running by name.")]
HRESULT IsServiceRunning(
          [in] BSTR ServiceName,
          [out, retval] VARIANT* pRunning);

[id(0x60030007), helpstring("Determine if the current user can start/stop the named service.")]
HRESULT CanStartStopService(
          [in] BSTR ServiceName,
          [out, retval] VARIANT* pCanStartStop);

[id(0x60030008), helpstring("Show/Hide browser bar.")]
HRESULT ShowBrowserBar(
          [in] BSTR bstrClsid,
          [in] VARIANT bShow,
          [out, retval] VARIANT* pSuccess);

[id(0x60040000), helpstring("Add an object to the Recent Docuements")]
HRESULT AddToRecent(
          [in] VARIANT varFile,
          [in, optional] BSTR bstrCategory);

[id(0x60050000), helpstring("Windows Security")]
HRESULT WindowsSecurity();

[id(0x60050001), helpstring("Raise/lower the desktop")]
HRESULT ToggleDesktop();

[id(0x60050002), helpstring("Return explorer policy value")]
HRESULT ExplorerPolicy(
          [in] BSTR bstrPolicyName,
          [out, retval] VARIANT* pValue);

[id(0x60050003), helpstring("Return shell global setting")]
HRESULT GetSetting(
          [in] long lSetting,
          [out, retval] VARIANT_BOOL* pResult);

  下面给例子,ShellApp.VBS,在 Win2003 测试通过:

Dim objSHA

Set objSHA = CreateObject( "Shell.Application" )

' 层叠窗口
objSHA.CascadeWindows

' 打开“Internet 选项”控制面板
objSHA.ControlPanelItem( "inetcpl.cpl" )

' 日期和时间 属性
objSHA.SetTime

' 打开任务栏属性
objSHA.TrayProperties

' 打开 C 盘
objSHA.Explore "C:\"

' 运行
objSHA.FileRun

'关机对话框
objSHA.ShutdownWindows

' 搜索文件
objSHA.FindFiles

' 打开 “我的电脑”
objSHA.ShellExecute "explorer.exe", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"

' 检测打印机服务是否在运行
MsgBox objSHA.IsServiceRunning( "Spooler" )

' 显示桌面
objSHA.ToggleDesktop

' Windows 安全
' 这个功能很多人用模拟 Ctrl+Alt+Del 的办法实现,代码千百行,难怪人称牛人!
'
Shell.Application 版本 4 有方法可以直接调用了!
objSHA.WindowsSecurity

Set objSHA = Nothing

  还是一句话:百度一下这些函数名,会有很多例子的!


类别:wsh 专栏 | 添加到搜藏 | 分享到i贴吧 | 浏览() | 评论 (3)
 
最近读者:
 
网友评论:
4
2007年06月09日 星期六 05:43 | 回复
Shell.Application 挺好用的,适合网管.
 
5
2007年07月20日 星期五 10:32 | 回复
我用exeScope打开shell32.dll,没发现有shell.application对象呀。怎么知道哪些方法和属性是shell.application的呀。现在都搞糊涂了。有高手吗。加我QQ:253828958,小弟谢谢大家了。
 
6
2007年07月20日 星期五 14:46 | 回复
Shell.Application 不是这样看出来的,这是 ProgID,COM DLL 在注册的时候写到注册表里,可以在 DLL 的资源 REGISTRY 里看到,这是使用 ATL 写的 DLL 才有,也就是说不一定有。 在 TYPELIB 里名字是 Dispatch IShellDispatch4
 
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu