首页 | 互联网 | IT动态 | IT培训 | Cisco | Windows | Linux | Java | .Net | Oracle | 软件测试 | C/C++ | 嵌入式开发 | 存储世界 | 服务器
网络设备 | IDC | 安全 | 求职招聘 | 数字网校 | 网页设计 | 平面设计 | 技术专题 | 电子书下载 | 教学视频 | 源码下载 | 搜索 | 博客 | 论坛
ASP | ASP.NET | JSP | PHP | AJAX | XML | Java script | HTML/CSS | 服务器类
各大城市软件开发培训、软件人才免费咨询热线:400-700-5807
 您现在的位置: 中国IT实验室 >> WEB开发 >> asp学习教程 >> 正文
Shell.Application对象使用
ChinaItLab  2007-10-22  保存本文  佚名  收藏本站

1、创建 Shell 对象
var Shell = new ActiveXObject("Shell.Application");

2、使用 Shell 属性及方法

Shell.Application
Shell.Parent

Shell.CascadeWindows()
Shell.TileHorizontally()
Shell.TileVertically()
Shell.ControlPanelItem(sDir) /* 比如:sysdm.cpl */
Shell.EjectPC()
Shell.Explore(vDir)
Shell.Open(vDir)
Shell.FileRun()
Shell.FindComputer()
Shell.FindFiles()
Shell.Help()
Shell.MinimizeAll()
Shell.UndoMinimizeALL()
Shell.RefreshMenu()
Shell.SetTime()
Shell.TrayProperties()
Shell.ShutdownWindows()
Shell.Suspend()
oWindows = Shell.Windows() /* 返回ShellWindows对象 */
fFolder = Shell.NameSpace(vDir) /* 返回所打开的vDir的Folder对象 */
oFolder = Shell.BrowseForFolder(Hwnd, sTitle, iOptions [, vRootFolder]) /* 选择文件夹对话框 */
/*示例:
function BrowseFolder()
{
var Message = "清选择文件夹";

var Shell = new ActiveXObject( "Shell.Application" );
var Folder = Shell.BrowseForFolder(0,Message,0x0040,0x11);
if(Folder != null)
{
Folder = Folder.items(); // 返回 FolderItems 对象
Folder = Folder.item(); // 返回 Folderitem 对象
Folder = Folder.Path; // 返回路径
if(Folder.charAt(varFolder.length-1) != "\\"){
Folder = varFolder + "\\";
}
return Folder;
}
}
*/

/*示例:
var Folder = Shell.NameSpace("C:\\"); // 返回 Folder对象
*/

3、使用 Folder 对象

[ oApplication = ] Folder.Application // Contains the Application object.
[ oParentFolder= ] Folder.ParentFolder // Contains the parent Folder object.
[ oTitle = ] Folder.Title // Contains the title of the folder.

Folder.CopyHere(vItem [, vOptions]) // Copies an item or items to a folder.
Folder.MoveHere(vItem [, vOptions]) // Moves an item or items to this folder.
/*
vItem: Required. Specifies the item or items to move. This can be a string that represents a file name, a FolderItem object, or a FolderItems object.
vOptions Optional. Specifies options for the move operation. This value can be zero or a
combination of the following values. These values are based upon flags defined for use with the
fFlags member of the C++ SHFILEOPSTRUCT structure. These flags are not defined as such for
Microsoft? Visual Basic?, Visual Basic Scripting Edition (VBScript), or Microsoft JScript?, so you
must define them yourself or use their numeric equivalents.
4 Do not display a progress dialog box.
8 Give the file being operated on a new name in a move, copy, or rename operation if a file with
the target name already exists.
16 Respond with "Yes to All" for any dialog box that is displayed.
64 Preserve undo information, if possible.
128 Perform the operation on files only if a wildcard file name (*.*) is specified.
256 Display a progress dialog box but do not show the file names.
512 Do not confirm the creation of a new directory if the operation requires one to be created.
1024 Do not display a user interface if an error occurs.
2048 Version 4.71. Do not copy the security attributes of the file.
4096 Only operate in the local directory. Don't operate recursively into subdirectories.
9182 Version 5.0. Do not move connected files as a group. Only move the specified files.
*/


Folder.NewFolder(bName) // Creates a new folder.
ppid = Folder.ParseName(bName) // Creates and returns a FolderItem object that represents a specified item.
/*
bName: Required. A string that specifies the name of the item.
*/

oFolderItems = Folder.Items() // Retrieves a FolderItems object that represents the collection of items in the folder.
sDetail = Folder.GetDetailsOf(vItem, iColumn) // Retrieves details about an item in a folder. For example, its size, type, or the time of its last modification.
/*
vItem: Required. Specifies the item for which to retrieve the information. This must be a FolderItem object.
iColumn: Required. An Integer value that specifies the information to be retrieved. The
information available for an item depends on the folder in which it is displayed. This value
corresponds to the zero-based column number that is displayed in a Shell view. For an item in the
file system, this can be one of the following values:0 Retrieves the name of the item.
1 Retrieves the size of the item.
2 Retrieves the type of the item.
3 Retrieves the date and time that the item was last modified.
4 Retrieves the attributes of the item.
-1 Retrieves the info tip information for the item.
*/

4、使用 FolderItems 对象

/*示例:
var FolderItems = Shell.NameSpace("C:\\").Items(); // 返回 FolderItems 对象
*/

[ oApplication = ] FolderItems.Application
[ iCount = ] FolderItems.Count
[ oParent = ] FolderItems.Parent

oFolderItem = FolderItems.Item([iIndex]) // 返回 FolderItem 对象

5、使用 FolderItem 对象

/*示例:
var FolderItem = Shell.NameSpace("C:\\").Items().Item(iIndex); //
 返回 FolderItems 对象
*/

[ oApplication = ] FolderItem.Application
[ oParent = ] FolderItem.Parent
[ sName = ] FolderItem.Name(sName) [ = sName ]
[ sPath = ] FolderItem.Path
[ iSize = ] FolderItem.Size
[ sType = ] FolderItem.Type
[ bIsLink = ] FolderItem.IsLink
[ bIsFolder = ] FolderItem.IsFolder
[ bIsFileSystem = ] FolderItem.IsFileSystem
[ bIsBrowsable = ] FolderItem.IsBrowsable
[ oGetLink = ] FolderItem.GetLink // 返回 ShellLinkObject 对象
[ oGetFolder = ] FolderItem.GetFolder // 返回 Folder 对象
[ oModifyDate= ] FolderItem.ModifyDate(oModifyDate) [ = oModifyDate ] // Sets or retrieves the date and time that the item was last modified.

vVerb = FolderItem.Verbs() // 返回 FolderItemVerbs 对象. This obj
ect is the collection of verbs
that can be executed on the item.
FolderItem.InvokeVerb( [vVerb]) // Executes a verb on the item.


6、使用 FolderItemVerbs 对象

/*示例:
var FolderItem = Shell.NameSpace("C:\\").Items().Item(iIndex).Verbs(); // 返回 FolderItems 对象
*/

[ oApplication = ] FolderItemVerbs.Application
[ oParent = ] FolderItemVerbs.Parent
[ iCount = ] FolderItemVerbs.Count

oVerb = FolderItemVerbs.Item( [iIndex]) // 返回 FolderItemVerb 对象.

7、使用 FolderItemVerb 对象

/*示例:

var FolderItem = Shell.NameSpace("C:\\").Items().Item(iIndex)
.Verbs().Item(iIndex); // 返回 FolderItems 对象
*/

[ oApplication = ] FolderItemVerbs.Application
[ oParent = ] FolderItemVerbs.Parent
[ oName = ] FolderItemVerbs.Name

FolderItemVerb.DoIt() // Executes a verb on the FolderItem as
sociated with the verb.

8、使用 ShellLinkObject 对象

[ sWorkingDirectory = ]ShellLinkObject.WorkingDirectory(sWork
ingDirectory) [ = sWorkingDirectory ]
[ intShowCommand = ]ShellLinkObject.ShowCommand(intShowCommand)
 [ = intShowCommand ]
/*
intShowCommand Integer that specifies or receives the link's s
how state. This can be one of the
following values.
1 Activates and displays a window. If the window is minimized
or maximized, the system restores
it to its original size and position.
2 Activates the window and displays it as a minimized window.
3 Activates the window and displays it as a maximized window.
*/
[ sArguments = ] ShellLinkObject.Arguments(sArguments) [ = sArguments ]
[ sDescription = ] ShellLinkObject.Description(sDescription) [ = sDescription ]
[ iHotkey = ] ShellLinkObject.Hotkey(iHotkey) [ = iHotkey ]
/*
iHotkey Integer that specifies or receives the link's hot key
 code. The virtual key code is in
the low-order byte, and the modifier flags are in the high-o
rder byte. The modifier flags can be a
combination of the following values.
1 SHIFT key
2 CTRL key
4 ALT key
8 Extended key
*/
[ sPath = ] ShellLinkObject.Path(sPath) [ = sPath ]

iIcon = ShellLinkObject.GetIconLocation(sPath)
ShellLinkObject.Resolve(fFlags)
/*
fFlags Required. Flags that specify the action to be taken. This can
 be a combination of the following values.
1 Do not display a dialog box if the link cannot be resolved. When
this flag is set, the high-
order word of fFlags specifies a time-out duration, in milliseconds.
 The method returns if the link
cannot be resolved within the time-out duration. If the high-order
word is set to zero, the time-out
duration defaults to 3000 milliseconds (3 seconds).
4 If the link has changed, update its path and list of identifiers.
8 Do not update the link information.
16 Do not execute the search heuristics.
32 Do not use distributed link tracking.
64 Disable distributed link tracking. By default, distributed link tracking tracks removable
media across multiple devices based on the volume name. It also use
s the Universal Naming Convention
(UNC) path to track remote file systems whose drive letter has cha
ged. Setting this flag disables
both types of tracking.
128 Call the Microsoft? Windows? Installer.
*/
ShellLinkObject.Save( [sFile])
ShellLinkObject.SetIconLocation(sPath, iIndex)
/*
sPath Required. String value that contains the fully qualified path
of the file that contains the icon.
iIndex Required. Integer that is set to the index of the icon in the
file specified by sPath.
*/

9、使用 ShellWindows 对象
[ intCount = ] ShellWindows.Count

oShellWindows = ShellWindows._NewEnum() // Creates and returns a new
 ShellWindows object that is a copy of this ShellWindows object.
oFolder = ShellWindows.Item( [iIndex]) // Retrieves an InternetE
xplorer object that represents the Shell window.

 

10、说明
通过第一步创建 Shell 对象,并进行相关函数调用,就可以返回以上各种对象,并进行相关操作。
另外,在学习的过程中,发现了两个在msdn中提及却没相关的函数:
ShellApp.ShellExecute("cmd.exe");
ShellApp.NameSpace(vDir).Items().InvokeVerbEx(vVerb); /*vVerb:如delete*/

还有些特殊的用法:
//var myprinterfolder = Shell.NameSpace("shell:PrintersFolder");
//var mydocsfolder = Shell.NameSpace("shell:personal");
//var mycompfolder = Shell.NameSpace("shell:drivefolder");

//Shell.ShellExecute( "wiaacmgr.exe","/SelectDevice" );
//Shell.ShellExecute( "rundll32.exe", "shell32.dll,Control_RunDLL
sysdm.cpl,,1" )
//Shell.ShellExecute( "rundll32.exe", "shell32.dll,Control_RunDLL
netcpl.cpl,,1" );
//Shell.ShellExecute( "rundll32.exe", "shell32.dll,Control_RunDLL
sysdm.cpl,,1" );

The following command will run Rundll32.exe.
Rundll32.exe <dllname>,<entrypoint>,<optional arguments>

The following code sample shows how to use the command.
Rundll32.exe Setupx.dll,InstallHinfSection 132 C:\Windows\Inf\Shell.inf


//Shell.ShowBrowserBar("{C4EE31F3-4768-11D2-BE5C-00A0C9A83DA1}", true);

真不知道,没有公开的函数调用还有多少,而msdn给我们的使用的只是九牛一毛而已!


11、使用 Shell.UIHelper.1 对象

ShellUI = new ActiveXObject("Shell.UIHelper.1");

ShellUI.AddChannel(sURL)
ShellUI.AddFavorite(sURL [, vTitle])
bBool = ShellUI.IsSubscribed(sURL) // Indicates whether or not a URL
 is subscribed to.
ShellUI.AddDesktopComponent(sURL, sType [, Left] [, Top] [, Width]
[, Height])
/*
sURL Required. A String value that specifies the URL of the new favorite item.
sType Required. A String value that specifies the type of item being
added. This can be one of the following values:
image The component is an image.
website The component is a web site.

Left Optional. Specifies the position of the left edge of the com
ponent, in screen coordinates.
Top Optional. Specifies the position of the top edge of the componen
t, in screen coordinates.
Width Optional. Specifies the width of the component, in screen units.
Height Optional. Specifies the height of the component, in screen units.
*/


Rundll 32.exe User.exe,ExitWindows

function FileSearch()
{
SearchAsst = new ActiveXObject("SearchAssistantOC.SearchAssistantOC");
SearchAsst.FindFilesOrFolders();
//ShellApp = new ActiveXObject("Shell.Application");
//ShellApp.ShowBrowserBar("{C4EE31F3-4768-11D2-BE5C-00A0C9A83DA1}", true);
//与上效果相同
}

function PersonSearch()
{
SearchAsst = new ActiveXObject("SearchAssistantOC.SearchAssistantOC");
SearchAsst.FindPeople();
}

function ShellExecuteExe()
{
ShellApp = new ActiveXObject("Shell.Application");

//var myprinterfolder = shell.NameSpace("shell:PrintersFolder");
//var mydocsfolder = shell.NameSpace("shell:personal");
//var mycompfolder = shell.NameSpace("shell:drivefolder");


//ShellApp.ShowBrowserBar("{C4EE31F3-4768-11D2-BE5C-00A0C9A83DA1}", true);

ShellApp.ShellExecute("cmd.exe");

//ShellApp.ShellExecute("wiaacmgr.exe","/SelectDevice");
//ShellApp.ShellExecute("rundll32.exe", "shell32.dll,Control_RunDLL
sysdm.cpl,,1")
//ShellApp.ShellExecute("rundll32.exe", "shell32.dll,Control_RunDLL
netcpl.cpl,,1");
//ShellApp.ShellExecute("rundll32.exe", "shell32.dll,Control_RunDLL
sysdm.cpl,,1");

//对于FolderItems对象可以用InvokeVerbEx Method
//ShellApp.NameSpace("c:\\xxx").Items().InvokeVerbEx("delete");
//而通过InvokeVerb(x.Items().Item(0).Verbs().Item(i).Name);可以访问某个命令
// win = ShellApp.NameSpace("c:\\xxx").Items().Item(0)
// e = win.Verbs();
// for(i=0;i<e.Count;i++){
// document.writeln(e.Item(i).Name);
// }
// win.InvokeVerb(e.Item(0).Name);

[1] [2] 下一页

中国IT教育热线咨询
相关文章
asp根据表单自动生成sql语句的函数
ASP连接11种数据库的语法总结
教你优化你的ASP程序
asp去除HTML标记的三个实用函数
ASP添加验证码的解决方法
最新文章
·PHP正则表达式从url中取得域名
·php设计模式介绍之迭代器模式
·简单学习php遇到的主要问题
·asp根据表单自动生成sql语句的函
·雅虎选项卡特效
 文章评论

 精彩友情推荐
·Asp源码 PHP源码
·CGI源码 JSP源码
·建站书籍教程
·服务器软件 .net源码
·建站工具软件
·IDC资讯大全
·机房品质万里行
·IDC托管必备知识
·全国IDC报价
·网站推广优化
ASP.NET ASP PHP JSP
·extjs ComboBox联动下拉菜单示例08-01
·漫谈.Net开发关于命名空间和目录划分07-31
·在Silverlight应用程序中操作Cookie07-28
·带附加条件的NewID()用法(downmoon)07-28
·对自定义路由进行单元测试07-28
·javascript实现yield07-28
·在ASP.NET中使用Google Maps07-28
·Sql Server2005 实现Oracle10g的hash表分区功07-28
·asp.net get set用法07-26
·Asp.net 控件开发—数据回传07-26
·接口vs. 的实体类07-26
·php设计模式介绍之迭代器模式08-02
·简单学习php遇到的主要问题08-02
·asp根据表单自动生成sql语句的函数08-02
·教你优化你的ASP程序03-07
·asp去除HTML标记的三个实用函数03-07
·ASP添加验证码的解决方法03-07
·ASP通用文章分页函数:非记录集分页03-07
·ASP教程基础:十天学会ASP第三天03-07
·ASP教程基础:十天学会ASP第二天03-07
·ASP教程基础:十天学会ASP第一天03-07
·能够生成google xml地图的asp源码03-06
·Linux系统下让PHP提高性能的工具APC05-06
·一个完整、安全的PHP用户登录系统11-14
·Apache+PHP+MySQL建立数据库驱动的动态网站08-24
·用SSH与PHP相连接 确保数据传输的安全性08-23
·PHP5手动最简安装方法08-03
·PHP程序加速探索之服务器负载测试07-11
·完全讲解PHP+MySQL的分页显示示例分析05-30
·用Suhosin加强PHP脚本语言安全性05-26
·初学入门 PHP 和 MySQL05-17
·传奇的诞生 PHP三位创始人简介05-10
·大型系统上PHP令人不爽的九大原因05-10
·ASP.NET和PHP、JSP究竟学哪个?07-30
·JAVA (Jsp)利用Google的Translate开发API07-29
·由Servlet获得FacesContext及ManagedBeans07-24
·用JOTM向Servlet中添加事务07-18
·用servlet生成验证码07-16
·JSP/Servlet伪静态网页实现07-08
·JSP和Servlet的关系浅谈06-15
·妙用异步Servlet扩展AJAX应用程序06-11
·servlet生成验证码图片06-02
·java.servlet.Filter的应用05-30
·Java程序员必看--扩展鼠标右键菜单功能05-13
  培训中心
人才交流中心 技术交流中心
  ITLab技术交流平台: