/*示例:
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 对象
*/
vVerb = FolderItem.Verbs() // 返回 FolderItemVerbs 对象. This object 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 对象
*/
FolderItemVerb.DoIt() // Executes a verb on the FolderItem associated with the verb.
8、使用 ShellLinkObject 对象
[ sWorkingDirectory = ]ShellLinkObject.WorkingDirectory(sWorkingDirectory) [ = sWorkingDirectory ]
[ intShowCommand = ]ShellLinkObject.ShowCommand(intShowCommand) [ = intShowCommand ]
/*
intShowCommand Integer that specifies or receives the link's show 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-order 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 uses the Universal Naming Convention (UNC) path to track remote file systems whose drive letter has changed. 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.
*/
oShellWindows = ShellWindows._NewEnum() // Creates and returns a new ShellWindows object that is a copy of this ShellWindows object.
oFolder = ShellWindows.Item( [iIndex]) // Retrieves an InternetExplorer object that represents the Shell window.
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 component, in screen coordinates.
Top Optional. Specifies the position of the top edge of the component, 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.
*/
Options,浏览方式,见下:
0x0001 For finding a folder to start document searching
0x0002 For starting the Find Computer
0x0004 对话框加宽
0x0008 确定按钮变灰失效
0x0010 在对话框顶部加入编辑框
0x0020 insist on valid result (or CANCEL)
0x1000 确定按钮变灰失效
0x2000 可选当前文件,不包括子目录文件,确定按钮变灰失效,(可同时选0x0001使确定按钮有效)
0x4000 浏览所有项,可选文件或文件夹
(21) NameSpace
返回指定文件夹的Folder类目标,例如:
var fol=Oh.NameSpace("c:\\");//返回C盘Folder类目标
var fol=Oh.NameSpace(0x001a);//返回系统C:\WINDOWS\Application Data目录Folder类目标
(三)Windows类
可通过Shell类的Windows方法得到Windows类目标,见上节。既返回系统进程中所有的shell window,这些shell可以是文件夹、IE浏览器、资源管理器,如我们打开资源管理器和一个网页,并在"我的电脑"中打开一个文件夹,那么将有一个Windows类目标,包括三个子Windows,Count属性值将为3,见下:
<html>
<script>
var Oh= new ActiveXObject("Shell.Application");
alert(Oh.Windows().Count);
</script>
</html>
(1)若想得到文件sdr.txt的属性,可用以下实现:
var fitem=Oh.NameSpace("e:\\zxd\\").ParseName("sdr.txt");//先得到sdr.txt的FolderItem类目标
alert(Oh.NameSpace("c:\\zxd\\").GetDetailsOf(fitem,0/*属性参数*/));//得到子目录或字文件的属性
属性参数:
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.