Scripting QTP - CH11 - Shell32
Scripting QTP - CH11 - Shell32
[Link] Property..................................................................... 25
[Link] Property........................................................................ 26
[Link] Property ................................................................. 26
[Link] Property ................................................................ 27
[Link] Property........................................................................ 27
[Link] Property .......................................................................... 27
[Link] Property.................................................................. 27
[Link] Property ........................................................................... 27
[Link] Property........................................................................... 28
[Link] Property.............................................................................. 28
[Link] Property.............................................................................. 28
[Link] Property ............................................................................ 28
[Link] Method ................................................................... 29
[Link] Method ............................................................................ 30
[Link], SHELL.FOLDERITEMS2, SHELL.FOLDERITEMS3 OBJECTS.......... 32
[Link] Property ......................................................................... 32
[Link] Method ............................................................................. 32
[Link] Method............................................................ 33
[Link] Property........................................................................ 33
[Link] Method .......................................................................... 33
[Link] OBJECT .............................................................................. 35
[Link] Property.................................................................... 35
[Link] Method ....................................................................... 36
[Link] OBJECT ............................................................................ 36
[Link] Property.................................................................. 37
[Link] Method ..................................................................... 37
[Link] INTERFACE AND SHELL OBJECT ............................................ 37
[Link] Property.................................................................................... 37
[Link] Method .................................................................................. 37
[Link] Method........................................................................ 38
[Link] Method ............................................................................ 38
[Link] Method ............................................................................ 39
[Link] Method ........................................................................................... 40
[Link] Method ........................................................................................... 40
[Link] Method ................................................................................ 41
[Link] Method ........................................................................................... 42
[Link] Method ................................................................................. 42
[Link] Method ......................................................................................... 43
[Link] Method ...................................................................................... 44
[Link] Method ....................................................................................... 45
[Link] Method .................................................................... 45
[Link] Method ................................................................................................ 46
[Link] Method ..................................................................................... 47
[Link] Method ............................................................................ 48
[Link] Method.................................................................................... 48
[Link] Method ..................................................................................... 49
[Link] Method ............................................................................................... 49
[Link] Method................................................................................... 50
[Link] Method ..................................................................................... 50
[Link] Method ................................................................................... 50
[Link] Method........................................................................................... 51
DiskQuotaControl The NTFS file system allows an administrator to manage disk usage on a
shared volume by allocating a specified amount of disk space, or quota
Disk quotas are an integral part of the NTFS file system. When a file or a folder is
created on a volume formatted with NTFS, that item is assigned an owner (typically
the user who created the item). NTFS obtains the user ID of the file owner and
stores that information in the file or folder's Standard Information attribute. This
attribute tallies all the disk space allocated to the file or folder. NTFS then locates
the quota entry for that user and determines whether the new allocation of disk
space causes the user to exceed the assigned quota. If it does, NTFS then takes
the appropriate steps, which can include logging an entry in the System event log
or preventing the user from creating the file or folder. As the file or folder changes
size, NTFS updates the quota control entry to reflect the total disk space used by
the user.
Disk quotas are not configured on a computer-wide basis, but are instead tied to
individual NTFS volumes. Each drive has separate quota settings, and the actions
you take on one volume do not affect the other volumes.
When managing disk quotas on a computer, the actions you take on one volume do
not affect the other volumes in any way. If you allocate User A 50 MB of disk space
on drive C, this does not also give User A 50 MB of disk space on drives D and E. If
you disable disk quotas on drive D, quotas remain enabled on drives C and E.
[Link] Object
Each user on the volume that is managed by the DiskQuotaControl object has a
DIDiskQuotaUser object associated with it. This object allows a client to manage
an individual user's settings. There are several ways to obtain a user's
DIDiskQuotaUser object:
The DIDiskQuotaUser objects for all users with quotas on the volume are
exposed as a collection and can be enumerated. A discussion of how to
enumerate DIDiskQuotaUser objects is found below.
When you add a new user, the AddUser method returns the user's
DIDiskQuotaUser object.
If you have the user's name, the FindUser method returns the user's
DIDiskQuotaUser object.
The DIDiskQuotaUser objects for all users with a quota on the volume are
exposed as a collection. The DiskQuotaControl object exports a standard
enumerator method that allows you to enumerate the collection of
DIDiskQuotaUser objects.
[Link] Property
[Link] Property
[Link] Property
This property contains the user's "friendly name." Its value is not
necessarily defined.
[Link] Property
The ID property retrieves an identifier (ID) that uniquely identifies the user.
Data Type
Integer value that uniquely identifies the user's DIDiskQuotaUser object
within a particular DiskQuotaControl process.
[Link] Property
[Link] Property
The QuotaLimit property sets or retrieves the user's current quota limit, in
bytes.
Data Type
Integer value that specifies or receives the user's current quota limit, in bytes.
[Link] Property
The QuotaLimitText property sets or retrieves the user's current quota limit,
in bytes.
Data Type
String value that contains the user's current quota limit.
[Link] Property
[Link] Property
[Link] Property
The QuotaUsed property retrieves the user's current disk usage, in bytes.
Data Type
Integer value that is set to the amount of disk space currently in use. If NTFS
file compression is enabled, QuotaUsed reflects the amount of disk space that
the data would require in an uncompressed state.
[Link] Property
The QuotaUsedText property retrieve the user's current disk usage as a text
string.
Data Type
String value that is set to the amount of disk space currently in use. If NTFS
file compression is enabled, this property reflects the amount of disk space that
the data would require in an uncompressed state.
[Link] Method
[Link]()
Return Value
No return value.
This method clears the user information stored in the object's cache. The
next time a request is made for quota-related information, the object
retrieves the information from the NTFS volume and refreshes the cache.
DiskQuotaControl Object
The NTFS file system allows an administrator to manage disk usage on a shared
volume by allocating a specified amount of disk space, or quota limit, to each user.
The DiskQuotaControl object allows an administrator to manage a volume's disk
quota properties. For instance, you can use this object to set the default quota
limit that will be automatically assigned to all new users.
Manage the folder structure to make files easy for users to locate.
Ensure that the proper versions of specific files are installed and updated when
necessary.
Track files and folders, periodically culling files and folders that are no longer
used.
Move files and folders from one location to another as circumstances dictate.
Create and manage shared folders to provide access to files from anywhere
within the organization.
[Link] Property
Example
Option Explicit
Dim oShell, oSpFoldersColl
Set oShell = CreateObject("[Link]")
Set oSpFoldersColl = [Link]
MsgBox [Link]
[Link] Property
[Link] Property
bytes.
[Link] Property
[Link] Property
[Link] Property
indicates whether a system event log entry will be made when a user exceeds
his or her assigned quota threshold.
Data Type
This property is set to TRUE if a system event log entry is made when the user
exceeds his or her quota warning threshold, or FALSE otherwise.
[Link] Property
[Link] Property
[Link] Property
The QuotaState property sets or retrieves the state of the volume's disk
quotas.
Data Type
Integer, The property can be set to one of the QuotaStateConstants defined in
Table 1 on page 61
[Link] Property
[Link] Method
[Link] (sLogonName)
Arguments
Parameter Description
Required. String value that contains the user's logon name. Use the
sLogonName UserNameResolution property to specify how the name is to be
resolved.
Return Value
No return value.
The NTFS file system automatically creates a user quota entry when a user
first writes to the volume.
Entries that are created in this way are assigned the default warning
threshold and hard quota limit values for the volume.
This method allows you to create a user quota entry before a user writes
information to the volume. It returns a DIDiskQuotaUser object that can
be used to assign a warning threshold or quota limit value that differs from
the default settings for the volume.
If the user already exists, no new entry is created. The method returns the
DIDiskQuotaUser object associated with the existing entry.
[Link] Method
Syntax
[Link] (oUser)
Arguments
Parameter Description
Required. Object expression that evaluates to the user's
oUser
DIDiskQuotaUser object.
Return Value
No return value.
This method fails if the user owns any storage on the volume. Before you
delete a user from a volume, all storage for that user must be deleted, be
moved to another volume, or have its ownership transferred to another
[Link] default settings for the volume.
[Link] Method
The FindUser method finds a user's entry, by name, in the volume's quota file.
Syntax
[Link] (sLogonName)
Arguments
Parameter Description
sLogonName Required. String value that contains the user's logon name.
[Link]
Method
[Link] (oUser)
Arguments
Parameter Description
Required. Object expression that evaluates to the user's
oUser
DIDiskQuotaUser object.
Return Value
No return value.
[Link] Method
Arguments
Parameter Description
Required. String value that contains the fully qualified path of the volume
sPath
to be initialized.
bReadWrite Required. Boolean value that specifies how the volume is to be opened.
Return Value
No return value.
[Link] Method
[Link]
Return Value
No return value.
Users' names and associated security IDs are stored in a cache. You can
clear this cache by calling InvalidateSidNameCache.
If you subsequently create a new user object, the information will have to be
obtained from the domain controller, and the cache will have to be
reestablished.
[Link] Method
[Link]
Return Value
No return value.
The security identifier (SID) name resolver translates SID to user names on
a background thread.
This thread is shut down automatically when the associated quota control
object is destroyed. However, there are some cases when the thread is no
longer needed, but the object is not yet ready to be destroyed.
A typical example is when no further processing is taking place, but clients
are still holding references to the object.
The ShutdownNameResolution method allows you to terminate the
resolver thread and free the associated resources without destroying the
quota control object.
When you shut down the resolver thread, asynchronous name resolution
[Link] Method
[Link] (logonname)
Arguments
Parameter Description
logonname Required. String value that specifies the user's logon name.
Return Value
No return value.
The returned SID string can be passed to the FindUser method in place of
a logon name.
When a call to the FindUser( logonname) method fails, it could be due to a
mismatch between the form (Security Account Manager [SAM]
compatible vs. User Principal Name [UPN]) of the logon name provided
and the form stored in the SID-name cache. In such cases, the logon name
can be converted to a SID and the call to FindUser repeated. FindUser
recognizes a SID string and will bypass the SID-name cache lookup.
Name-to-SID translation can be a slow process when compared to lookups
in the SID-name cache. Therefore, it is recommended that FindUser first
be called with a logon name.
Example
the logon name can be translated to a SID string using
TranslateLogonNameToSID then passed again to FindUser.
Function Find(ByVal oDQC, ByVal sName)
On Error Resume Next
Set Find = [Link](sName)
If [Link] <> 0 Then
[Link]
Set Find = [Link]([Link](sName))
End If
End Function
Set oDQC = Nothing
The Folder object represents a Shell folder. It contains properties and methods
[Link] Property
Note Not all methods are implemented for all folders. For example, the
ParseName method is not implemented for the Control Panel folder
(CSIDL_CONTROLS). If you attempt to call an unimplemented method, a
0x800A01BD (decimal 445) error is raised.
Example
The following code implements the ParentFolder property to retrieve the
Folder object.
Option Explicit
Private Const ssfPROGRAMS = 2
Dim oShell32, oFolder, oParentFolder
'--- Creating a shell application object
Set oShell32 = CreateObject("[Link]")
Set oFolder = [Link](ssfPROGRAMS)
'--- Checking Folder object validation
If (Not oFolder Is Nothing) Then
'--- Retrieving the parent folder object
Set oParentFolder = [Link] '--- usually "Start Menu".
Msgbox [Link]
End If
Set oParentFolder = Nothing : Set oFolder = Nothing : Set oShell32 = Nothing
[Link] Property
Note Not all methods are implemented for all folders. For example, the
ParseName method is not implemented for the Control Panel folder
(CSIDL_CONTROLS). If you attempt to call an unimplemented method, a
0x800A01BD (decimal 445) error is raised.
Example
The following example uses Title to retrieve the title of the folder holding the
[Link] Method
[Link](vItem, vOptions)
Arguments
Parameter Description
Required. Specifies the item or items to copy. This can be a string that
vItem
represents a file name, a FolderItem object, or a FolderItems object.
Optional. Specifies options for the copy operation. This value can be zero
vOptions or a combination of the of the SHFILEOPSTRUCT structure values
described in Table 5 on page 62
Return Value
No return value.
Not all methods are implemented for all folders. For example, the
ParseName method is not implemented for the Control Panel folder
(CSIDL_CONTROLS). If you attempt to call an unimplemented method, a
0x800A01BD (decimal 445) error is raised.
Example
The following example uses CopyHere to copy the [Link] file from the
root directory to the C:\Windows directory
Option Explicit
Private Const FOF_FILESONLY = 128
Private Const FOF_NOCONFIRMATION = 16
Dim oShell32, oFolder
'--- Creating the shell application file
Set oShell32 = CreateObject("[Link]")
Set oFolder = [Link]("C:\Windows")
If Not oFolder Is Nothing Then
'--- Copy to folder all files under temp with
'--- flag for use regular expression and
'--- flag to avoid confirmation dialog
[Link] "C:\temp\*.*", FILESONLY + FOF_NOCONFIRMATION
End If
'--- Cleaning objects
Set oFolder = Nothing : Set oShell32 = Nothing
[Link] Method
[Link](vItem, iColumn)
Arguments
Parameter Description
Required. Specifies the item or items to copy. This can be a string that
vItem
represents a file name, a FolderItem object, or a FolderItems object.
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
iColumn 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 Details Options Values in Table 6 on page 63
Return Value
String containing the retrieved detail.
Not all methods are implemented for all folders. For example, the
ParseName method is not implemented for the Control Panel folder
(CSIDL_CONTROLS). If you attempt to call an unimplemented method, a
0x800A01BD (decimal 445) error is raised.
Example
The following example uses GetDetailsOf to retrieve the type of the file named
[Link].
Option Explicit
Private Const colInfoTip = -1
Dim oShell32, oFolder, oFolderItem
Dim sInfo
'--- Creating the shell application file
Set oShell32 = CreateObject("[Link]")
'--- Retrieving a folder object using the namespace method
Set oFolder = [Link]("C:\Windows")
'--- Checking Folder validation
If not oFolder is nothing then
'--- Retrieving the file item object
Set oFolderItem = [Link]("[Link]")
'--- Checking file item validation
If (Not oFolderItem Is Nothing) then
'--- Retrieving the info tip information for the item.
sInfo = [Link](oFolderItem, colInfoTip)
MsgBox sInfo, 0, "Info Tip Information"
End if
Set oFolderItem = Nothing
End if
'--- Cleaning objects
Set oFolder = Nothing : Set oShell32 = Nothing : Set oFolderItem = Nothing
[Link] Method
[Link]()
Not all methods are implemented for all folders. For example, the
ParseName method is not implemented for the Control Panel folder
(CSIDL_CONTROLS). If you attempt to call an unimplemented method, a
0x800A01BD (decimal 445) error is raised.
Example
The following example uses Items to determine the number of items in the
C:\Program Files folder.
Option Explicit
Dim oShell32, oFolder, oFolderItem
Dim nCount
'--- Creating the shell application file
Set oShell32 = CreateObject("[Link]")
'--- Retrieving a folder object using the namespace method
Set oFolder = [Link](CSIDL_PROGRAM_FILES)
'--- Checking Folder validation
If not oFolder is nothing then
'--- Retrieving all files items object
Set oFolderItems = [Link]
'--- Checking file item validation
If (Not oFolderItems Is Nothing) then
'--- Retrieving the count iformation.
nCount = [Link]
MsgBox nCount, 0, "Number of items under C:\Windows"
End if
Set oFolderItems = Nothing
End if
'--- Cleaning objects
Set oFolder = Nothing : Set oShell32 = Nothing
[Link] Method
Description
[Link](vItem, vOptions)
Arguments
Parameter Description
Required. Specifies the item or items to copy. This can be a string that
vItem
represents a file name, a FolderItem object, or a FolderItems object.
Optional. Specifies options for the copy operation. This value can be zero
vOptions or a combination of the of the SHFILEOPSTRUCT structure values
described in Table 5 on page 62
Not all methods are implemented for all folders. For example, the
ParseName method is not implemented for the Control Panel folder
(CSIDL_CONTROLS). If you attempt to call an unimplemented method, a
0x800A01BD (decimal 445) error is raised.
Example
The following example uses MoveHere to move the all the files in MyTemp from
the root directory of the C:\ drive to the C:\MyTempFolder folder, with a
progress bar.
Option Explicit
Private Const FOF_FILESONLY = 128
Private Const FOF_SIMPLEPROGRESS = 256
Dim sPath
Dim oShell32, oFolder
'--- Creating the shell application file
Set oShell32 = CreateObject("[Link]")
'--- Retrieving a folder object using the namespace method
Set oFolder = [Link]("C:\MyTempFolder")
'--- Checking Folder validation
If Not oFolder Is Nothing Then
'--- Moving to oFolder
sPath = "C:\Program Files\Mercury Interactive\MyTemp\*.*"
[Link] sPath, FOF_FILESONLY + FOF_SIMPLEPROGRESS
End If
'--- Cleaning objects
Set oFolder = Nothing : Set oShell32 = Nothing
[Link] Method
[Link](sName, vOptions)
Arguments
Parameter Description
sName Required. A string that specifies the name of the new folder.
vOptions Optional. This value is not currently used.
Return Value
No return value.
Not all methods are implemented for all folders. For example, the
ParseName method is not implemented for the Control Panel folder
(CSIDL_CONTROLS). If you attempt to call an unimplemented method, a
0x800A01BD (decimal 445) error is raised.
Example
The following example uses NewFolder to create the new folder C:\TestFolder.
Option Explicit
Dim oShell32, oFolder
'--- Creating the shell application file
Set oShell32 = CreateObject("[Link]")
'--- Retrieving a folder object using the namespace method
Set oFolder = [Link]("C:\Windows")
'--- Checking Folder validation
If not oFolder is nothing then
'--- Creating a new folder
[Link]("TestFolder")
End if
'--- Cleaning objects
Set oFolder = Nothing : Set oShell32 = Nothing
[Link] Method
[Link](sName)
Arguments
Parameter Description
sName Required. A string that specifies the name of the item.
Return Value
An object reference to the FolderItem object.
[Link] Property
Description
The OfflineStatus property contains Contains the offline status of the folder.
Data Type
Integer that is set to one of the [Link] values described in
Table 4 on page 61
[Link] Property
The Self property contains Contains the offline status of the folder.
Data Type
Integer that is set to one of the [Link] values described in
Table 4 on page 61
C:\Windows folder.
Option Explicit
Private Const CSIDL_WINDOWS = 36
Dim oShell32, oFolder, oFolderItem
'--- Creating the shell application file
Set oShell32 = CreateObject("[Link]")
'--- Retrieving a folder object using the namespace method
Set oFolder = [Link](CSIDL_WINDOWS)
'--- Checking Folder validation
If Not oFolder Is Nothing Then
Set oFolderItem = [Link]
If (Not oFolderItem Is Nothing) Then
'Add code here.
End if
End if
'--- Cleaning objects
Set oFolder = Nothing : Set oShell32 = Nothing : Set oFolderItem = Nothing
[Link] Method
[Link]()
Call this method after the Web view barricade is dismissed by the user
[Link] Method
Description
The Synchronize method sychronizes all offline files.
Syntax
[Link] ()
[Link] Object
[Link] Property
The GetFolder property contains the item's Folder object, If the item is a
folder.
[Link] Property
The GetLink property contains the item's ShellLinkObject object, If the item
is a shortcut
[Link] Property
[Link] Property
The IsFileSystem property indicates if the item is part of the file system.
[Link] Property
[Link] Property
[Link] Property
The ModifyDate property sets or retrieves the date and time that a file was
last modified. ModifyDate can be used to retrieve the data and time that a
folder was last modified, but cannot set it.
Data Type
Date that specifies or receives the date and time that the item was last
modified.
[Link] Property
Data Type
String that specifies or receives the item's name.
[Link] Property
[Link] Property
The Path property contains the item's full path and name.
Data Type
String that receives the item's full path and name.
[Link] Property
[Link] Property
[Link] Method
[Link] (vVerb)
Arguments
Parameter Description
Optional. A string that specifies the verb to be executed. It must be one
vVerb of the values returned by the item's [Link] property. If
no verb is specified, the default verb will be invoked.
Return Value
No return value.
Example2
The following example uses InvokeVerb to invoke the verb "properties".
Option Explicit
Private Const CSIDL_WINDOWS = 36
Dim oShell32, oFolder, oFolderItem
'--- Creating a shell application object
Set oShell32 = CreateObject("[Link]")
Set oFolder = [Link](CSIDL_WINDOWS)
'--- Checking Folder object validation
If (Not oFolder Is Nothing) Then
'--- Retrieve the FolderItem object
Set oFolderItem = [Link]
'--- Validation...
If (Not oFolderItem Is Nothing) Then
'--- Invoking the verb 'Properties'
[Link]("Properties")
End if
Set oFolderItem = nothing
End If
'--- Cleaning objects
Set oFolder = Nothing : Set oShell32 = Nothing
[Link] Method
Description
The Verbs method retrieves the item's FolderItemVerbs object. This object is
[Link]()
Return Value
An object reference to the FolderItemVerbs object.
[Link] Property
[Link] Method
The Item method retrieves the FolderItem object for a specified item in the
collection.
Syntax
[Link](nIndex)
Arguments
Parameter Description
Optional. Specifies the zero-based index of the item to retrieve. This
nIndex
value must be less than the value of the Count property.
Return Value
An object reference to the FolderItem object.
[Link] Method
Description
The InvokeVerbEx method executes a verb on a collection of FolderItem
objects. This method is an extension of the InvokeVerb method, allowing
additional control of the operation through a set of flags.
Syntax
Arguments
Parameter Description
Optional. Variant with the verb string that corresponds to the command
vVerb
to be executed. If no verb is specified, the default verb is executed.
Optional. Variant that consists of a string with one or more arguments to
vArgs the command specified by vVerb. The format of this string depends on
the particular verb.
Return Value
No return value.
[Link] Property
The Verbs property retrieves the list of verbs common to all the folder items.
Data Type
Collection of FolderItemVerbs to be returned.
[Link] Method
The Filter method sets a wildcard filter to apply to the items returned.
Syntax
Arguments
Parameter Description
Required. This parameter can be one of the flags listed in SHCONTF
grfFlags
Enumerated Type Values.
bstrFilter Required. Contains a filter string.
Return Value
No return value.
[Link] Object
[Link] Property
[Link] Method
The DoIt method Executes a verb on the FolderItem associated with the verb.
Syntax
[Link] ()
Return Value
No return value.
[Link] Object
[Link] Property
Description
The Count property contains the number of items in the collection.
Data Type
Integer that receives the Count property.
[Link] Method
The Item method retrieves the FolderItemVerb object for a specified item in
the collection.
Syntax
[Link] (nIndex)
Arguments
Parameter Description
Required. Specifies the zero-based index of the item to retrieve. This
nIndex
value must be less than the value of the Count property
Return Value
Object that receives the FolderItemVerb object.
The Shell object represents the objects in the Shell. Methods are provided to
control the Shell and to execute commands within the Shell. There are also
methods to obtain other Shell-related objects.
[Link] Property
[Link] Method
Description
The AddToRecent method determines if the current user can start and stop the
named service.
Syntax
Arguments
Parameter Description
Required. Variant that specifies the file to add to the list of recently used
varFile
documents.
Optional. String that contains the name of the category in which to place
bstrCategory
the file.
Return Value
No return value..
[Link] Method
The CanStartStopService method determines if the current user can start and
stop the named service.
Syntax
[Link] (sServiceName)
Arguments
Parameter Description
sServiceName Required. String that contains the name of the service.
Return Value
Returns True if the user can start and stop the service, or False otherwise.
Example
The following example shows the proper usage of CanStartStopService inside a
public function
Public Function fCanStartStopService(ByVal sServiceName)
Dim oShell32
Set oShell32 = CreateObject("[Link]")
fCanStartStopService = [Link](sServiceName)
Set oShell32 = nothing
End function
[Link] Method
Description
The CascadeWindows method Cascades all of the windows on the desktop.
This method has the same effect as right-clicking the taskbar and selecting
Cascade Windows.
Syntax
[Link] ()
Return Value
No return value.
[Link] Method
[Link] (sDir)
Arguments
Parameter Description
Required. Specifies the Control Panel application's file name. All Control
sDir
Panel applications have the .cpl extension.
Return Value
No return value.
Example
The following example uses ControlPanelItem to run the Control Panel's
Display Properties item.
Option Explicit
Dim oShell32
'--- Creating a shell application object
Set oShell32 = CreateObject("[Link]")
[Link]("[Link]")
'--- Cleaning objects
Set oShell32 = Nothing
[Link] Method
The EjectPC method ejects the computer from its docking station. This is the
same as clicking the Start menu and selecting Eject PC, if your computer
supports this command.
Syntax
[Link]()
Return Value
No return value.
[Link] Method
[Link](vDir)
Arguments
Parameter Description
vDir Required. Specifies the folder to be displayed. This can be a string that
specifies the path of the folder or one of the ShellSpecialFolderConstants
values.
Example
The following example shows Explore in use.
Option Explicit
Private Const CSIDL_PERSONAL = 5
Dim oShell32
'--- Creating a shell application object
Set oShell32 = CreateObject("[Link]")
[Link](CSIDL_PERSONAL)
'--- Cleaning objects
Set oShell32 = Nothing
[Link] Method
[Link] (bstrPolicyName)
Arguments
Parameter Description
bstrPolicyName Required. String that specifies the name of the Internet Explorer policy.
Return Value
Variant that receives the value of the specified Internet Explorer policy.
[Link] Method
[Link]()
Return Value
No return value.
[Link] Method
[Link] ()
Return Value
No return value.
[Link] Method
The FindFiles method Displays the Find: All Files dialog box. This is the same
as clicking the Start menu, selecting Find, and then selecting Files or Folders.
Syntax
[Link] ()
Return Value
No return value.
[Link] Method
The FindPrinter method displays the Find Printer dialog box to allow the user
to find a printer.
Syntax
Arguments
Parameter Description
sName Optional. String that contains the printer name.
sLocation Optional. String that contains the printer location.
sModel Optional. String that contains the printer model.
Return Value
No return value.
If you assign strings to one or more of the optional parameters, they are
displayed as default values in the associated edit control when the Find
Printer dialog box is displayed.
The user can either accept or override these values. If no value is assigned
to a parameter, the associated edit box is empty and the user must enter a
value.
[Link] Method
[Link] (nSetting)
Arguments
Parameter Description
Required. A value of type Integer that specifies the current Shell
nSetting settings to retrieve. The SHGetSetSettings Enumerated Type described
on Table 10 on page 66.
Return Value
Boolean that returns true if the setting exists, or false otherwise.
[Link] Method
[Link] (sName)
Arguments
Parameter Description
Return Value
Returns the requested system information value. The return type depends on
what system information is requested.
[Link] Method
The Help method displays the Microsoft Windows Help and Support Center. This
method has same effect as clicking the Start menu and selecting Help and
Support.
Syntax
[Link] ()
Return Value
No return value.
[Link] Method
The IsRestricted method retrieves the registry's data value for a given group's
restriction value.
Syntax
Arguments
Parameter Description
sGroup Required. The group (key) name under which to check for the restriction.
sRestriction Required. The restriction whose data value is to be retrieved.
Return Value
The value of the restriction. If the specified restriction is not found, the return
value is 0.
IsRestricted first looks for a registry key name matching sGroup under the
following key.
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies
[Link] Method
[Link] (sServiceName)
Arguments
Parameter Description
sServiceName Required. String that contains the service's name.
Return Value
Returns true if the service specified by sServiceName is running, or false
otherwise.
Example
The following example shows the proper usage of IsServiceRunning inside a
public function
Public Function fIsServiceRunning(ByVal sServiceName)
Dim oShell32
Set oShell32 = CreateObject("[Link]")
fIsServiceRunning = [Link](sServiceName)
Set oShell32 = nothing
End function
[Link] Method
The Help method Minimizes all of the windows on the desktop. This method has
the same effect as right-clicking the taskbar and selecting Minimize All Windows
on older systems or clicking the Show Desktop icon in the Quick Launch area of
the taskbar in Microsoft Windows 2000 or Windows XP.
Syntax
[Link] ()
Return Value
No return value.
[Link] Method
The NameSpace method creates and returns a Folder object for the specified
folder.
Syntax
[Link] (vDir)
Arguments
Parameter Description
Required. Specifies the folder for which to create the Folder object. This
can be a string that specifies the path of the folder or one of the
vDir
[Link] values in Table 7–
[Link] Values on page 65.
Return Value
Object reference to the Folder object for the specified folder. If the folder is not
successfully created, this value returns null.
Example
The following example shows NameSpace in use.
Public Function fGetShellNameSpace(ByVal vDir, ByRef sTitle)
Dim oShell32, oFolder
Set oShell32 = CreateObject("[Link]")
Set oFolder = [Link](vDir)
If (Not objFolder Is Nothing) then
sTitle = [Link]
End If
set oFolder = Nothing
set oShell32 = Nothing
End function
[Link] Method
[Link] (vDir)
Arguments
Parameter Description
Required. Specifies the folder for which to create the Folder object. This
can be a string that specifies the path of the folder or one of the
vDir
[Link] values in Table 7–
[Link] Values on page 65.
Return Value
No return value.
[Link] Method
The RefreshMenu method refreshes the contents of the Start menu. Used only
with systems preceeding Microsoft Windows XP.
Syntax
[Link] ()
Return Value
No return value.
Remarks
The functionality that RefreshMenu provides is handled automatically under
Windows XP or later. Do not call this method under that operating system.
[Link] Method
Arguments
Parameter Description
sServiceName Required. String that contains the service's name.
Required. Variant that is set to true to have the service started by the
vPersistent service control manager when ServiceStart is called. To leave the
service configuration unchanged, set vPersistent to false.
Return Value
Returns true if successful, or false otherwise.
[Link] Method
[Link](sFile,vArguments,vDirectory,vOperation,vShow)
Arguments
Parameter Description
Required. String that contains the name of the file on which
sFile
ShellExecute will perform the action specified by vOperation.
vArguments Optional. Variant that contains the parameter values for the operation.
Optional. Variant that contains the fully qualified path of the directory
vDirectory that contains the file specified by sFile. If this parameter is not specified,
the current working directory is used.
Optional. Variant that specifies the operation to be performed. It should
be set to one of the verb strings that is supported by the file. For a
vOperation
discussion of verbs, see the Remarks section. If this parameter is not
specified, the default operation is performed.
Optional. Variant that recommends how the window that belongs to the
vShow application that performs the operation should be displayed initially. The
application can ignore this recommendation.
vShow can take one of the following values. If this parameter is not specified,
the application uses its default value.
Value Description
0 Open the application with a hidden window.
Open the application with a normal window. If the window is minimized or
1
maximized, the system restores it to its original size and position.
2 Open the application with a minimized window.
3 Open the application with a maximized window.
Open the application with its window at its most recent size and position. The
4
active window remains active.
5 Open the application with its window at its current size and position.
Open the application with a minimized window. The active window remains
7
active.
Open the application with its window in the default state specified by the
10
application.
Remarks
This method is equivalent to launching one of the commands associated with
a file's shortcut menu. Each command is identified by a verb string. The
supported verbs vary from file to file. The most commonly supported verb is
"open", which is also usually the default verb. Others might be supported
only by certain types of files.
[Link] Method
The SetTime method Displays the Date and Time Properties dialog box. This
method has the same effect as right-clicking the clock in the taskbar status area
and selecting Adjust Date/Time.
Syntax
[Link] ()
[Link] Method
Professional
The ShowBrowserBar method stops a named service.
Syntax
Arguments
Parameter Description
Required. String that contains the string form of the class identifier
(CLSID) of the browser bar to be displayed. The object must be
sCLSID
registered as an Explorer Bar object with a CATID_InfoBand
component category.
Required. Variant that is set to true to show the browser bar, or false
vShow
to hide it.
Return Value
Variant. Returns true if successful, or false otherwise.
You can display one of the standard Explorer Bars by setting sCLSID to its
CLSID string. The standard Explorer Bars and their CLSID strings are as
follows.
Explorer Bar CLSID string
Favorites {EFA24E61-B078-11d0-89E4-00C04FC9E26E}
Folders {EFA24E64-B078-11d0-89E4-00C04FC9E26E}
History {EFA24E62-B078-11d0-89E4-00C04FC9E26E}
Search {30D02401-6A81-11d0-8274-00C04FD5AE38}
[Link] Method
Displays the Shut Down Windows dialog box. This is the same as clicking the
Start menu and selecting Shut Down.
Syntax
[Link] ()
Return Value
No return value.
[Link] Method
[Link]()
Return Value
No return value.
[Link] Method
The TileHorizontally method Tiles all of the windows on the desktop vertically.
This method has the same effect as right-clicking the taskbar and selecting Tile
Windows Vertically..
Syntax
[Link] ()
Return Value
No return value.
[Link] Method
[Link] ( )
Return Value
No return value.
Remarks
This method behaves like the toggle desktop icon on the quick launch bar. It
hides all open windows and shows the desktop, or hides the desktop and
shows all open windows.
The ToggleDesktop method does not display any user interface, it just
invokes the toggle action.
This methos is similar to MinimizeAll
[Link] Method
The TrayProperties method Displays the Taskbar and Start Menu Properties
dialog box. This method has the same effect as right-clicking the taskbar and
selecting Properties.
Syntax
[Link]()
Return Value
No return value.
Figure 16 – Task
[Link] Method
[Link] ()
Return Value
No return value.
[Link] Method
The Windows method Creates and returns a ShellWindows object. This object
represents a collection of all of the open windows that belong to the Shell.
Syntax
[Link] ()
Return Value
Object reference to the ShellWindows object.
[Link] Method
[Link] ( )
Return Value
No return value.
Remarks
Using this method provides the same results as pressing CTRL+ALT+DELETE
or using the security option that is on the Start menu when you connect
using Microsoft Terminal Server.
This method will work only when connected via a terminal session to
[Link] Object
The Shell object represents the objects in the Shell. Methods are provided to
control the Shell and to execute commands within the Shell. There are also
methods to obtain other Shell-related objects.
[Link] Property
[Link] Object
This object extends the FolderItem object. In addition to the properties and
methods supported by FolderItem, ShellFolderItem has two additional methods.
[Link] Method
[Link] ( sPropName )
Arguments
Parameter Description
Required. String value that specifies the property. See the Remarks
sPropName
section for details.
Return Value
Variant. Returns the value of the property, if it exists for the specified item. The
value will have full typingfor example, dates will be returned as dates, not
strings.
Remarks
This method returns a zero-length string if the property is valid but does not
exist for the specified item, or an OLE error code otherwise.
There are two ways to specify a property. The first is to assign the property's
Q&A
Option Explicit
Const CSIDL_COMMON_ADMINTOOLS = &H2f
Dim oShell, oFolder, oItem
Dim nRow : nRow = 1
Option Explicit
Const CSIDL_MYMUSIC = 13
Dim oShell, oFolder, oItem
Dim nRow : nRow = 1
'--- Creating an entry in local datasheet
[Link] "ITEM_NAME", ""
'--- Creating a new shell application object
Set oShell = CreateObject("[Link]")
Set oFolder = [Link](CSIDL_MYMUSIC)
'--- Retrieving collection of items
For Each oItem in [Link]
[Link] nRow
DataTable("ITEM_NAME", dtLocalSheet) = [Link]
nRow = nRow + 1
Next
Set oShell = Nothing
Option Explicit
Const CSIDL_COMMON_DESKTOPDIR = 25
Dim oShell, oFolder, oFolderItem
Dim nRow : nRow = 1
'--- Creating an entry in local datasheet
[Link] "ITEM_NAME", ""
'--- Creating a new shell application object
Set oShell = CreateObject("[Link]")
Option Explicit
Dim oComp
Dim sInfo
Set oComp = CreateObject("[Link]")
sInfo = "Computer name: " & [Link] & vbCrLf
sInfo = sInfo & "Shutdown allowed: " & [Link] & vbCrLf
sInfo = sInfo & "Friendly UI enabled: " & [Link] & vbCrLf
sInfo = sInfo & "Guest access mode: " & [Link] & vbCrLf
sInfo = sInfo & "Guest account enabled: " & [Link](0) & vbCrLf
sInfo = sInfo & "Multiple users enabled: " & [Link] & vbCrLf
sInfo = sInfo & "Offline files enabled: " & [Link] & vbCrLf
sInfo = sInfo & "Remote conn. enabled: " & [Link] & vbCrLf
sInfo = sInfo & "Undock enabled: " & [Link] & vbCrLf
MsgBox sInfo, 0, "Local Computer Information"
Set oComp = Nothing
Option Explicit
Const CSIDL_FAVORITES = 6
Set oShell32, oShell, oFolder, oFolderItem, oURLShortcut
Dim sDesktopFld
'--- Creating a application object
Set oShell32 = CreateObject("[Link]")
Set oFolder = [Link](CSIDL_FAVORITES)
'--- Using the favorites folder for the path.
Set oFolderItem = [Link]
sDesktopFld = [Link]
'--- Creating a shell folder to use the URLShortcut object
Set oShell = CreateObject("[Link]")
Set oURLShortcut = [Link](sDesktopFld & "\MSDN [Link]")
[Link] = "[Link]
[Link]
'--- Cleaning
Set oURLShortcut = Nothing : Set oShell = Nothing : Set oComp = Nothing
QuotaStateConstants Values
Constant Value Description
dqStateDisable 0 Disk quotas are disabled.
dqStateTrack 1 Disk quotas are disabled.
UserNameResolutionConstants Values
Constant Val Description
dqResolveNone 0 Do not resolve user name information.
dqResolveSync 1 Wait while resolving name information.
dqResolveAsync 2 Do not wait while resolving name information. The OnUserNameChanged
event fires when the name is resolved.
QuotaStateConstants Values
Constant Value Description
dqAcctResolved 0 Account information is resolved.
dqAcctUnavailable 1 Account information is unavailable.
dqAcctDeleted 2 Account has been deleted.
dqAcctInvalid 3 Account is invalid.
dqAcctUnknown 4 Account cannot be found.
[Link] Values
Constant Value Description
OFS_DIRTYCACHE 3 Server is online with unsynchronized changes.
OFS_INACTIVE -1 Offline caching is not enabled for this folder.
OFS_OFFLINE 1 Server is offline.
OFS_ONLINE 0 Server is online.
OFS_SERVERBACK 2 Server is offline but can be reached.
SHFILEOPSTRUCT Values
Constant Value Description
FOF_SILENT 4 Do not display a progress dialog box.
Give the file being operated on a new name in a move,
FOF_RENAMEONCOLLISION 8 copy, or rename operation if a file with the target
name already exists.
Respond with "Yes to All" for any dialog box that is
FOF_NOCONFIRMATION 16
displayed.
FOF_ALLOWUNDO 64 Preserve undo information, if possible.
Perform the operation on files only if a wildcard file
FOF_FILESONLY 128
name (*.*) is specified.
Display a progress dialog box but do not show the file
FOF_SIMPLEPROGRESS 256
names.
Do not confirm the creation of a new directory if the
FOF_NOCONFIRMMKDIR 512
operation requires one to be created.
[Link] Values
Constant Val Description
The file system directory that is used to store administrative
tools for an individual user. The Microsoft Management
CSIDL_ADMINTOOLS 48
Console (MMC) will save customized consoles to this
directory, and it will roam with the user.
[Link] Values
Constant Val Description
SFVVO_SHOWALLOBJECTS 1 The Show All Files option is enabled.
The Hide File Extensions for Known File Types option is
SFVVO_SHOWEXTENSIONS 2
disabled.
The Display Compressed Files and Folders with Alternate
SFVVO_SHOWCOMPCOLOR 8
Color option is enabled.
SFVVO_SHOWSYSFILES 32 The Do Not Show Hidden Files option is enabled.
SFVVO_WIN95CLASSIC 64 The Classic Style option is enabled.
SFVVO_DOUBLECLICKINWEBVIEW 128 The Double-Click to Open an Item option is enabled.
SFVVO_DESKTOPHTML 512 The Active Desktop View as Web Page option is enabled.
option.
The state of the Show encrypted or compressed NTFS
SSF_SHOWCOMPCOLOR
files in color option.
The state of the Hide extensions for known file types
SSF_SHOWEXTENSIONS
option.
The state of the Show pop-up description for folder and
SSF_SHOWINFOTIP
desktop items option.
SSF_SHOWSTARTPAGE Not used.
SHCOLUMNID Values
PID Property Name Data Type
2 Title String
3 Subject String
4 Author String
5 Keywords String
6 Comments String
7 Template String
8 Last Saved By String