国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項超值服

開通VIP
shell 使用,獲取文件屬性內(nèi)容
使用 Shell 屬性及方法

使用 Shell 屬性及方法 
2011年07月13日
  1、創(chuàng)建 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 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 對象
  */
  [ 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 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.
  */
  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 InternetExplorer object that represents the Shell window.
  10、說明
  通過第一步創(chuàng)建 Shell 對象,并進(jìn)行相關(guān)函數(shù)調(diào)用,就可以返回以上各種對象,并進(jìn)行相關(guān)操作。
  另外,在學(xué)習(xí)的過程中,發(fā)現(xiàn)了兩個在msdn中提及卻沒相關(guān)的函數(shù):
  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 ,,
  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);
  真不知道,沒有公開的函數(shù)調(diào)用還有多少,而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 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.
  */
  Rundll 32.exe User.exe,ExitWindows
  --------------------------------------------------------------------------------
  (一)開始
  從WIN95起,WIN系統(tǒng)的一些基本功能被封裝在符合通用對象模式COM(Common Object Mode)標(biāo)準(zhǔn)的OLE組件中,在網(wǎng)頁上可通過JavaScript語言調(diào)用shell實現(xiàn)一些系統(tǒng)功能。用JavaScript調(diào)用shell是通過ActiveXObject來實現(xiàn)的,見下:
  
  
  var Oh= new ActiveXObject("Shell.Application");
  
  
  這樣將得到Shell類目標(biāo)。
  (二) Shell類
  Shell類包括以下方法:
  (1) BrowseForFolder 
  打開文件瀏覽對話框,BrowseForFolder是最實用的一種方法,它可以定位文件或文件夾,或定位系統(tǒng)文件夾,具體形式如下:
  Oh.BrowseForFolder(Hwnd,Title,Options,[RootFolder]);
  具體參數(shù):
  Hwnd,這里必須為0
  Title,對話框標(biāo)題字符串
  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 可選當(dāng)前文件,不包括子目錄文件,確定按鈕變灰失效,(可同時選0x0001使確定按鈕有效)
  0x4000 瀏覽所有項,可選文件或文件夾
  RootFolder,起始根目錄,可選項,可以自己指定目錄字符串,也可以是系統(tǒng)目錄的數(shù)字表示,數(shù)字含義見下:
  0x0000 桌面
  0x0001 IE瀏覽器
  0x0002 C:\WINDOWS\Start Menu\Programs目錄
  0x0003 控制面板
  0x0004 打印機(jī)
  0x0005 我的文檔
  0x0006 收藏
  0x0007 啟動
  0x0008 Recent文檔
  0x0009 發(fā)送到
  0x000a 回收站
  0x000b 開始菜單
  0x000c 桌面(打開在我的電腦) 
  0x0010 C:\WINDOWS\Desktop桌面目錄
  0x0011 我的電腦(包括所有驅(qū)動器)
  0x0012 整個網(wǎng)絡(luò)
  0x0013 NetHood
  0x0014 字體目錄
  0x0015 C:\WINDOWS\ShellNew目錄
  0x001a C:\WINDOWS\Application Data目錄
  0x001b printHood
  0x0020 C:\WINDOWS\Temporary Internet Files目錄
  0x0021 cookie目錄
  0x0022 IE瀏覽歷史
  如:
  Oh.BrowseForFolder(0,"測報軟件:",0x1000|0x0001,"D:\\OSSMO 2004"); 
  Oh.BrowseForFolder(0,"垃圾文件:",0x4000,0x000a); 
  Oh.BrowseForFolder(0,"請選擇目錄:",0x0000 ,"c:\\");
  BrowseForFolder 最后將返回用戶所選的文件或文件夾的Folder類目標(biāo),通過對Folder類目標(biāo)的處理得到所選目標(biāo)的完整路徑,例如:
  
  
  var Oh= new ActiveXObject("Shell.Application");
  var ob=Oh.BrowseForFolder(0,"我的文件夾:",0x1000|0x0001,0x0000); // 返回Folder目標(biāo)ob 
  if(ob&&ob.Items()&&ob.Items().Item()) alert("你選擇了目錄:"+ob.Items().Item().Path);
  else alert("你未做選擇");
  
  
  (2) Explore 
  用資源管理器打開文件夾,可用于下載文件,例如:
  Oh.Explore("c:\\"); //瀏覽C盤
  Oh.Explore("c:\\SCANDISK.LOG"); //本地下載
  (3) Open 
  打開文件夾,可用于下載文件,例如:
  Oh.Explore("c:\\"); //打開C盤
  (4) FileRun 
  打開運(yùn)行窗口,例如:
  Oh.FileRun();
  (5) SetTime 
  打開時間屬性設(shè)置對話框
  (6) ShutdownWindows 
  打開關(guān)閉計算機(jī)對話框
  (7) FindFiles 
  打開查找文件對話框
  (8) TrayProperties 
  打開任務(wù)欄屬性對話框
  (9) FindComputer 
  打開查找計算機(jī)對話框
  (10) Help 
  打開幫助文件, WIN98下無效
  (11) ControlPanelItem 
  打開控制面板中的某一項,例如:
  Oh.ControlPanelItem("C:\\WINDOWS\\SYSTEM\\DESK.CPL");//打開桌面屬性設(shè)置
  這里介紹一種定位控制面板中項目的方法:在控制面板選定一項--->單擊右鍵--->在桌面創(chuàng)建快捷方式--->選定快捷方式單擊右鍵--->按“更改圖標(biāo)”按鈕,在彈出的對話框上部有完整目錄。
  (12) CascadeWindows 
  層疊排列桌面上的所有窗口,包括最大化的窗口,不包括最小化的窗口
  (13) TileHorizontally 
  豎向排列桌面上的所有窗口
  (14) TileVertically 
  橫向排列桌面上的所有窗口
  (15) MinimizeAll 
  使桌面所有窗口圖標(biāo)化
  (16) UndoMinimizeALL 
  恢復(fù)最小化的窗口
  (17) EjectPC 
  未知,WIN98下無效
  (18) RefreshMenu 
  未知
  (19) Suspend 
  暫停計算機(jī),大概是使計算機(jī)進(jìn)入休眠狀態(tài)!!!!!!!!
  (20) Windows 
  返回shell的Windows類目標(biāo),例如: 
  Oh.Windows();
  (21) NameSpace 
  返回指定文件夾的Folder類目標(biāo),例如:
  var fol=Oh.NameSpace("c:\\");//返回C盤Folder類目標(biāo)
  var fol=Oh.NameSpace(0x001a);//返回系統(tǒng)C:\WINDOWS\Application Data目錄Folder類目標(biāo)
  (三)Windows類
  可通過Shell類的Windows方法得到Windows類目標(biāo),見上節(jié)。既返回系統(tǒng)進(jìn)程中所有的shell window,這些shell可以是文件夾、IE瀏覽器、資源管理器,如我們打開資源管理器和一個網(wǎng)頁,并在"我的電腦"中打開一個文件夾,那么將有一個Windows類目標(biāo),包括三個子Windows,Count屬性值將為3,見下:
  
  
  var Oh= new ActiveXObject("Shell.Application");
  alert(Oh.Windows().Count);
  
  
  各個子Windows可通過Item索引得到,如:
  Oh.Windows().Item(0).StatusBar=0;
  將去掉第一個子Windows的狀態(tài)欄,相似的過程還有
  Oh.Windows().Item(0).ToolBar=1;
  Oh.Windows().Item(0).StatusText="你好";
  Oh.Windows().Item(0).Quit();//關(guān)閉瀏覽器或資源管理器 *************************
  alert(Oh.Windows().Item(0).FullName);//瀏覽器或資源管理器程序全名
  alert(Oh.Windows().Item(0).LocationURL);//文件或網(wǎng)頁地址
  alert(Oh.Windows().Item(0).Path);//瀏覽器或資源管理器程序所在目錄
  對于IE瀏覽器有:
  Oh.Windows().Item(0).Document.write("123");
  alert(Oh.Windows().Item(0).Document.title);
  先打開資源管理器或IE瀏覽器,再運(yùn)行下列代碼,看看資源管理器的狀態(tài)欄有什么結(jié)果。
  
  
  
  function onck(){
  var Oh= new ActiveXObject("Shell.Application");
  Oh.Windows().Item(0).StatusText="你選定了一萬個對象,系統(tǒng)資源不足...";
  }
  
  
  (四)Folder類(文件夾)
  屬性:
  Application 
  Parent ??返回父Folder
  ParentFolder 返回父Folder
  Title 得到目錄名
  方法:
  CopyHere 拷貝,不支持中文文件名,支持目錄拷貝
  GetDetailsOf 
  Items 返回FolderItems目標(biāo)
  MoveHere 移動,不支持中文文件名,支持目錄移動
  NewFolder 新建,不支持
  ParseName 返回FolderItem目標(biāo) 
  GetDetailsOf 得到子目標(biāo)屬性
  用法:
  (1)若想得到文件sdr.txt的屬性,可用以下實現(xiàn):
  var fitem=Oh.NameSpace("e:\\zxd\\").ParseName("sdr.txt");//先得到sdr.txt的FolderItem類目標(biāo)
  alert(Oh.NameSpace("c:\\zxd\\").GetDetailsOf(fitem,0/*屬性參數(shù)*/));//得到子目錄或字文件的屬性
  屬性參數(shù):
  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. 
  (2)如將JavaScript.zip文件拷貝到e:\new\當(dāng)前目錄,可用以下實現(xiàn):
  var fitem=Oh.NameSpace("e:\\").Items().Item("JavaScript.zip");//先得到FolderItem類目標(biāo)
  Oh.NameSpace("e:\\new\\").CopyHere(fitem,0x0010/*拷貝參數(shù)*/);
  拷貝參數(shù)
  0x0001 ???磁盤被保護(hù)?
  0x0008 如果以存在目標(biāo)則形成“復(fù)件 JavaScript.zip”
  0x0010 如果以存在目標(biāo)不提示直接覆蓋
  (3)其他
  alert(Oh.NameSpace("c:\\windows\\help\\").Title);//得到父目錄
  Oh.NameSpace("e:\\zxd\\").Items();//得到FolderItems目標(biāo),既字目錄和文件集
  Oh.NameSpace("e:\\new\\").MoveHere(ob,0x0000);//移動
  (五)FolderItems類(文件夾下的文件集合,包括子文件夾)
  屬性:Count 子項目總數(shù)
  方法:Item 得到子文件,參數(shù)為文件名或索引數(shù)值
  用法:
  alert(Oh.NameSpace("c:\\zxd").Items().Count);//文件夾內(nèi)文件總數(shù),包括子文件夾
  alert(Oh.NameSpace("c:\\zxd\\").Items().Item("ts.exe"));//得到FolderItem文件目標(biāo)
  alert(Oh.NameSpace("c:\\zxd\\").Items().Item(3));//得到FolderItem文件目標(biāo)
  (六)FolderItem類(子文件)
  屬性:
  Application 
  GetFolder 如果此目標(biāo)是文件夾,該屬性將返回該目標(biāo)的Folder類
  GetLink 如果此目標(biāo)是快捷方式,該屬性將返回該目標(biāo)的IShellLinkDual類
  IsBrowsable 是否能被瀏覽
  IsFileSystem 是否文件
  IsFolder 是否文件夾
  IsLink 是否快捷方式
  ModifyDate 返回創(chuàng)建時間
  Name 名稱
  Parent 返回父目標(biāo)的FolderItem
  Path 返回目標(biāo)的完整路徑
  Size 大小
  Type 類型
  方法:
  InvokeVerb 打開目標(biāo)(運(yùn)行程序)
  Verbs 得到FolderItemVerbs類目標(biāo)
  用法:
  alert(Oh.NameSpace("e:\\").Items().Item("一些JS技術(shù).htm").name);//"一些JS技術(shù).htm" 支持中文
  alert(Oh.NameSpace("e:\\new\\").Items().Item("JavaScript.zip").Path);//得到文件path "E:\new\JavaScript.zip"
  alert(Oh.NameSpace("c:\\zxd\\").Items().Item("計算器.pif").GetLink);//得到源文件
  alert(Oh.NameSpace("c:\\zxd\\").Items().Item("計算器.pif").IsFolder);//是否文件夾IsLink,IsFileSystem,IsBrowsable
  alert(Oh.NameSpace("c:\\zxd\\").Items().Item("計算器.pif").date);
  alert(Oh.NameSpace("e:\\new\\").Items().Item("JavaScript.zip").Size);//得到文件大小 72259字節(jié),文件夾為0
  alert(Oh.NameSpace("e:\\new\\").Items().Item("JavaScript.zip").Type);//得到文件類型 "zip 文件" "文件夾"
  Oh.NameSpace("e:\\new").Items().Item("JavaScript.zip").InvokeVerb(od);//運(yùn)行
  Oh.NameSpace("c:\\zxd\\").ParseName("ts.exe").InvokeVerb();//運(yùn)行
  ---- 什么是Shell對象?具體來講,就是微軟對一些常用外殼操作函數(shù)的封裝。象打開或瀏覽一個文件夾、查找文件、關(guān)閉計算機(jī)等等,而且還能瀏覽整個文件系統(tǒng),獲取文件或文件夾的各種信息。由于這些封裝是建立在OLE自動化服務(wù)的基礎(chǔ)之上,所以我們就可以在VB和Web中方便的使用它們。 
  ---- 在VB中使用 
  ---- VB自身所提供的對象或函數(shù)的功能也許比較有限,但能夠引用各式各樣的類型庫和自動化對象就將其功能無限的擴(kuò)展了!具體做法如下(以中文VB6為例): 
  ---- 新建一個工程,在“工程”菜單中選擇“引用”,你將看到一個“引用對話框”,然后在“可用的引用”中選擇“Microsoft Shell Controls and Automation”,這樣你就可以在程序中使用Shell對象了。 
  ---- 下面來試一試Shell對象提供的方法。在窗體(Form1)中添加一個按扭(Button1),然后在Button1的Click事件中添加如下代碼: 
  Dim MyShell As Shell 
  Set MyShell = New Shell 
  MyShell.FindFiles 
  ---- 當(dāng)MyShell變量成為Shell對象的實例之后,你在編輯的過程中就可以看到Shell對象的所有方法。上面的代碼使用的是FindFiles方法,它將顯示“查找文件”對話框。下表給出了Shell對象中常用的方法,以供大家參考。 
  ---- 方法 描述 
  ---- BrowseForFolder 顯示瀏覽文件夾對話框,包括4個參數(shù): 
  ---- Hwnd, Title, Options, [RootFolder] 
  ---- Hwnd:包含對話框的窗體句柄(handle),一般設(shè)置為0。 Title:將在對話框中顯示的說明,為字符串。 
  ---- Options:使用對話框的特殊方式,為長整數(shù),一般設(shè)置為0。 
  ---- [RootFolder]:可選的,用來設(shè)置瀏覽的最頂層文件夾,缺省時為“桌面”,你可以將其設(shè)置為一個路徑或“特殊文件夾常數(shù)”。 
  ---- 該方法返回一個Folder對象。 
  ---- ControlPanelItem 運(yùn)行一個指定的控制面板項目,包括一個參數(shù): 
  ---- szDir:控制面板項目名 
  ---- Explore 用資源管理器瀏覽一個指定文件夾,包括一個參數(shù): 
  ---- vDir:一個路徑或“特殊文件夾常數(shù)” 
  ---- Open 打開一個指定文件夾,包括一個參數(shù): 
  ---- vDir:一個路徑或“特殊文件夾常數(shù)” 
  ---- FileRun 顯示“運(yùn)行”對話框 
  ---- FindComputer 顯示“查找計算機(jī)”對話框 
  ---- FindFiles 顯示“查找文件”對話框 
  ---- CascadeWindows 層疊排列桌面上所有窗口 
  ---- TileHorizontally 橫向排列桌面上所有窗口 
  ---- TileVertically 縱向排列桌面上所有窗口 
  ---- MinimizeAll 最小化所有窗口 
  ---- UndoMinimizeALL 恢復(fù)最小化的窗口 
  ---- EjectPC 注銷當(dāng)前用戶 
  ---- Suspend 將計算機(jī)掛起 
  ---- ShutdownWindows 顯示“關(guān)閉Windows”對話框 
  ---- NameSpace 用所給的文件夾路徑創(chuàng)建一個文件夾對象(Folder對象),使用Folder對象,你可以瀏覽整個文件系統(tǒng),獲取文件或文件夾的各種信息。 
  ---- 表中出現(xiàn)了“特殊文件夾常數(shù)”,那什么是特殊文件夾,象“我的電腦”,“控制面板”等等,在系統(tǒng)中是找不到相應(yīng)目錄的,還有“桌面”、“收藏夾”等一些Windows安裝后就產(chǎn)生的文件夾,也是特殊文件夾(0x表示16進(jìn)制)。 
  桌面:ssfDESKTOP = 0x0000 
  文檔:ssfSENDTO = 0x0009 
  收藏夾:ssfFAVORITES = 0x0006 
  打印機(jī):ssfPRINTERS = 0x0004 
  我的電腦:ssfDRIVES = 0x0011 
  控制面板:ssfCONTROLS = 0x0003 
  網(wǎng)絡(luò)鄰居:ssfNETWORK = 0x0012 
  ---- 有了這些提示和參考,再加上你的想象,一定能讓VB編出程序增色不少。 
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
BrowseForFolder使用,參數(shù)詳解
在XP系統(tǒng)中怎樣對文件夾加密
妙用Windows神秘的類標(biāo)識符
真正解決xp無法打開隱藏文件的方法(
Win7用戶文件夾轉(zhuǎn)移
使用離線文件夾
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服