Just create a new Class Module and then paste this source code into it. You should name the class cControlPanel.
'----------------------------------------------------------------------
'
' Module Name: cControlPanel
' Written By: C&D Programming Corp.
' Create Date: 2/99
' Copyright: Copyright 1999 by C&D Programming Corp. Source
' code may not be reproduced except for use in a
' compiled executable. All rights reserved. If
' you would like to reprint any or all of this
' code please email us at info@codeoftheweek.com
'----------------------------------------------------------------------
Option Explicit
'
' Much of the content of this class was derived from an article
' in Microsoft's knowledge base. Some of it is reprinted here for
' your use. For complete details, visit Microsoft's support pages
' at http://support.microsoft.com/support/kb/articles/q135/0/68.asp
' for this complete article.
'
'
'
'RUNDLL32 is a utility included with Windows 95, Windows 98, and Windows
'NT 4.0 that allows you to start a function that is exported from a DLL
'from a command-line. The shell uses RUNDLL32 to call the Control_RunDLL
'function in Shell32.dll to start a Control Panel applet. Applications
'can use the following command line to start a Control Panel applet:
'
'
' rundll32.exe shell32.dll,Control_RunDLL mycontrol.cpl
'
'NOTE: The command "Control_RunDLL" is case sensitive and must
'exactly match the case shown.
'This starts the first control panel applet in Mycontrol.cpl.
'If you have multiple control panel applets in Mycontrol.cpl,
'you need to add to the following line exactly as shown:
'
'
' rundll32.exe shell32.dll,Control_RunDLL mycontrol.cpl,@1
'
'@1 specifies the second (zero-based) applet in the .cpl file.
'
'If you don't specify this parameter, @0 is used by default.
'The final (optional) parameter serves as the command line
'parameters passed to the Control Panel applet in the CPL_STARTWPARM
'notification. For example, some of the system's Control Panel
'applets take the page number (one based, not zero based) as the
'command line parameter. For example, if you wan to start the
'Add/Remove Programs applet from the Windows Setup page so you
'can instruct the user to add extra system components, you can
'use this code:
'
'
' rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,@0,2
'
'NOTE: If you put a space after the comma in the commands above,
'the following error message will appear:
'
' Error in shell32.dll
' Missing entry.
'
'Article ID: Q135068
'
'Last Reviewed:
'December 30, 1998
'
' Copyright 1998 Microsoft Corp.
'
Public Function LaunchApplet(sDLLName As String, sEntryPoint As String, _
sAppletName As String, AppWinStyle As VbAppWinStyle) As Boolean
Dim lPid As Long
lPid = Shell("rundll32.exe " & sDLLName & "," & sEntryPoint & " " & sAppletName, AppWinStyle)
' there is no easy way to get the return value of rundll32.exe, so
' let's assume it always succeeds for now. We might cover this in
' a future issue of Code of the Week.
LaunchApplet = True
End Function
Public Function LaunchControlPanelApplet(sAppletName As String, _
Optional AppWinStyle As VbAppWinStyle = vbNormalFocus, _
Optional lTab As Long = -1, _
Optional lAppletNumber As Long = 0)
If lTab = -1 Then
LaunchControlPanelApplet = LaunchApplet("shell32.dll", "Control_RunDLL", sAppletName, AppWinStyle)
Else
LaunchControlPanelApplet = LaunchApplet("shell32.dll", "Control_RunDLL", _
sAppletName & ",@" & lAppletNumber & "," & lTab, AppWinStyle)
End If
End Function
Public Function AddRemovePrograms() As Boolean
AddRemovePrograms = LaunchControlPanelApplet("AppWiz.cpl", vbNormalFocus)
End Function
Public Function Joystick() As Boolean
Joystick = LaunchControlPanelApplet("joy.cpl", vbNormalFocus)
End Function
Public Function Display() As Boolean
Display = LaunchControlPanelApplet("desk.cpl", vbNormalFocus)
End Function
Public Function ScreenSaver() As Boolean
ScreenSaver = LaunchControlPanelApplet("desk.cpl", vbNormalFocus, 1)
End Function
Public Function System() As Boolean
System = LaunchControlPanelApplet("sysdm.cpl", vbNormalFocus)
End Function
Public Function SystemDevices() As Boolean
SystemDevices = LaunchControlPanelApplet("sysdm.cpl", vbNormalFocus, 1)
End Function