Launching System Applets in VB.NET

Description

This piece demonstrates the use of the shell statement in VB.NET. Various system calls are made using the Shell function. 

In many applications user is given the privilege to change the system settings. This code calls various system dialog boxes such as,

  • Accessibility options (General, keyboard, display, sound etc.),
  • Regional settings (Background, appearance, screensaver , settings),
  • Internet settings dialog box ,
  • Control Panel itself etc.

Procedure

On running this code a form is displayed. It has many options buttons. Depending on the selection the Applet is displayed. Close the previously opened dialog box to open the new one. 

Source Code

To launch the Accessibility Options applet

  • General
    rundll32.exe shell32.dll,Control_RunDLL access.cpl,,5
     
  • Display
    rundll32.exe shell32.dll,Control_RunDLL access.cpl,,3
     
  • Keyboard
    rundll32.exe shell32.dll,Control_RunDLL access.cpl,,1
     
  • Mouse
    rundll32.exe shell32.dll,Control_RunDLL access.cpl,,4
     
  • Sound
    rundll32.exe shell32.dll,Control_RunDLL access.cpl,,2

To launch the Regional Settings applet:

  • Background
    rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0
     
  • Appearance
    rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,2
     
  • Screen Saver
    rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,1
     
  • Settings
    rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3 

Additional information

When using the Shell command to launch a Control Panel applet, you must be careful to use the exact syntax for the RunDLL32 utility. The capitalization of all components in the statement must not be altered in any way-otherwise, an error will occur.

Each time you want to launch a Control Panel applet, your Visual Basic statement must include the syntax used above. In other words, you need only to substitute the name of the .CPL file for "main.cpl" used above and specify the number of the particular applet you want to execute. Also, if that applet requires additional command-line parameters, you would specify these as the last parameter to the statement.


Similar Articles