Use the shell object in the VB and web page
Department of Electronic Engineering, Optoelectronic Engineering, Wuhan Surveying and Mapping University
---- What is a shell object? Specifically, Microsoft's package for some common shell operation functions. Like open or browse a folder, find a file, turn off the computer, etc., and also browse the entire file system, obtain various information of the file or folder. Since these packages are based on the OLE automation service, we can use them in VB and Web.
---- Use in VB
---- The function of the object or function provided by VB itself may be limited, but it can be extended with a variety of type libraries and automation objects. The specific practices are as follows (as examples in Chinese VB6):
---- New project, select "Reference" in the Project menu, you will see a "Reference Dialog", then select "Microsoft Shell Controls and Automation" in "available reference" so you will You can use the shell object in the program.
---- Let's try the method provided by the Shell object. Add a button (Button1) in the form (Form1), then add the following code in the Click event of Button1:
Dim myshell as shell
Set myshell = new shell
MyShell.FindFiles
---- When the MyShell variable becomes an instance of the shell object, you can see all methods of the shell object during editing. The above code is used by the FindFiles method, which will display the Find File dialog. The following table gives the methods commonly used in the Shell object for reference.
---- Method Description
---- BrowseForfolder Displays the browsing folder dialog, including 4 parameters:
---- HWND, Title, Options, [rootfolder]
---- HWND: The form handle (Handle) containing the dialog, is typically set to 0. Title: The instructions will be displayed in the dialog as a string.
---- Options: Use the special way to use the dialog, for long integers, usually set to 0.
---- [rootfolder]: Optional, used to set the top-level folder for browsing, is "Desktop" when default, you can set it to a path or "special file clamping regular".
---- This method returns a Folder object.
---- ControlPanelItem runs a specified control panel project, including a parameter:
---- SZDIR: Control Panel Project Name
--- Explore browses a specified folder with the Explorer: including a parameter:
---- VDIR: A path or "special file clamp regular"
---- Open Opens a specified folder, including a parameter:
---- VDIR: A path or "special file clamp regular"
---- Filerun Displays "Run" dialog
--- FindComputer Display "Find Computer" dialog
---- FindFiles Display "Find File" dialog
---- CascadeWindows laminated all windows on the desktop
---- Tilehorizontally horizontally arranged on the desktop all windows
---- TileVerticalLy portrait arrangement on the desktop all windows
---- MinimizeAll Minimizes all windows
---- UndominimizeAll restores the minimized window
---- EJECTPC logouts the current user
---- Suspend will hang your computer
---- ShutDownWindows Displays "Close Windows" dialog ---- Namespace Creates a folder object with the folder path (Folder object), using the Folder object, you can browse the entire file system, get files or folders Various information.
---- Table has a "special file clamp regular number", that is a special folder, like "My Computer", "Control Panel", etc. Desktop, "Favorites", etc. After some Windows installation, the folder generated after installation is also a special folder (0x representation 16).
Desktop: SSFDesktop = 0x0000 Document: SSFsendto = 0x0009 Favorites: SSFFAVORITES = 0x0006 Printer: SSFPrinters = 0x0004 My Computer: SSFDRIVES = 0x0011 Control Panel: SSFControls = 0x0003 Network Neighbor: SSFNetwork = 0x0012
---- With these tips and references, plus your imagination, it will make the VB to have a lot of color.
---- Use in the web page
---- Since IE4 and its later version can support ActiveX, you can insert all kinds of ActiveX on the web page, so you can use the shell object.
---- You can use the
Content = "text / html; charSet = GB2312">
hEAD>
Function showItem ()
{
Var myfolder, myfolders;
Var s = ""; myfolder = shell.browseforfolder (0, "Please select a folder", 0);
myfolders = myfolder.Item.Items ();
For (VAR i = 0; i S = myfolders.Item (i) .Name " Return (s) } script>
";