Visual Basic Code of the Week (COTW)
Issue #77
Online Version at (paid subscribers only)
All content and source code is Copyright (c) 1999 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.

Special Deal

Get a LIFETIME subscription to Code of the Week for only $49.95 (regularly $59.95). Just jump to our SECRET order page at and see everything you get with this outstanding offer!

Cool Software

Download a free copy of NetMon - Your Internet Performance Monitor at

In this Issue

In this issue we show how to launch control panel applets.

This source code is designed for VB 5.0 32-bit and up. Questions? Email us at


The cControlPanel class module contains several routines to start some common control panel applets. It is very easy to customize for any additional applets you want to start.

If you have any questions about using this class, let us know at


Public Function LaunchControlPanelApplet(sAppletName As String, _
                    Optional AppWinStyle As VbAppWinStyle = vbNormalFocus, _
                    Optional lTab As Long = -1, _
                    Optional lAppletNumber As Long = 0)

This function provides the ability to launch any control panel applet with the information provided. The sAppletName is the CPL file to launch. See the Other Information section below for some examples. The AppWinStyle is what the window style will be when launched. For example, you might not want the window to get focus right away so you can set it to vbNormalNoFocus. This parameter is optional.

The lTab and lAppletNumber are also optional. The lTab parameter allows you to select which tab is shown when the applet is started. The lAppletNumber parameter allows you to start a particular applet within the sAppletName applet. Sometimes there are more than one applet in a single CPL file.

Public Function AddRemovePrograms() As Boolean

Launches the Add/Remove control panel applet.

Public Function Joystick() As Boolean

Launches the Joystick control panel applet.

Public Function Display() As Boolean

Launches the display properties control panel applet.

Public Function ScreenSaver() As Boolean

Launches the display properties control panel applet and then jumps to the screen saver tab.

Public Function System() As Boolean

Launches the system properties control panel applet.

Public Function SystemDevices() As Boolean

Launches the system properties control panel applet and then jumps to the device manager tab.


Currently these routines will always return True.

Other Information

Most CPL files are stored in the Windows System directory. You can use the Find Files feature to locate all the ones installed on your system. Some other common control panel applets that you might want to use are:

Sample Usage

The below sample describes how to use the cControlPanel class. It assumes you have created a form and added the following code to it. Make sure the form has a list box called lstApps and a command button called cmdActions.

Option Explicit

Private Sub cmdAction_Click()
    Dim ControlPanel As New cControlPanel

    With ControlPanel
        Select Case lstApps.ListIndex
            Case 0
            Case 1
            Case 2
            Case 3
            Case 4
            Case 5
        End Select
    End With
End Sub

Private Sub Form_Load()
    lstApps.AddItem "Add/Remove Programs"
    lstApps.AddItem "Joystick"
    lstApps.AddItem "Display"
    lstApps.AddItem "Screen Saver"
    lstApps.AddItem "System Properties"
    lstApps.AddItem "System Devices"
    cmdActions.Caption = "Execute"
End Sub

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address:

This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945