XTreme Logo

If you appreciate these tips, please consider a small donation:

General Tip - Novice

How To:
Launch Windows Control Panel Extensions Using VB

Tested on WIN95 OSR2 using VB5 ENT SP3
This VB Tip is provided courtesy of our friend:
Joseph Terranova (terran684@hotmail.com | jterran@tp.net)

Did you ever want to show one of the Windows Control Panels
(e.g., Regional Settings) from your VB app? This quick routine grabs
a list of Control Panel Extension (.CPL) files and displays them in a
FileListBox. You can then select a .CPL file from the list and click a
CommandButton to show the Control Panel dialog associated with that file.

Start a new Standard EXE Project. Form1 is created by default.

Add a FileListBox (File1) and a CommandButton (Command1) to Form1.
___________________________________

Option Explicit

Private strPanelName As String

Private Sub Command1_Click()
    strPanelName = File1.filename
    If strPanelName = "" Then
        MsgBox "A .CPL file was not selected." & vbCrLf & _
        "The Windows Control Panel will be opened.",vbInformation
    End If
    Shell "rundll32.exe shell32.dll,Control_RunDLL " & _
             strPanelName, vbNormalFocus
End Sub

Private Sub Form_Load()
    With File1
       
'Display Control Panel Extension files only:
        .Pattern = "*.CPL"
       
'Point the FileListBox to the System or System32 dir:
        .filename = "C:\Windows\System"
    End With
End Sub


[ Back To The Top ]

Contact: web@xtremecomp.com
All contents copyright XTreme Computing unless noted otherwise.