Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Open a Control Panel dialog or wizard
[ All Languages » VB »  Windows]

Total Hit ( 2669)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Have you ever needed to open a Windows dialog such as Internet Properties, New Hardware, Modem Properties or any other dialog you can find in the Control Panel? Well, it's very simple, onve you know the trick.

All these dialogs are implemented in files with the CPL extension. (They're actually DLLs with their extension changed.) All you have to do is call the appropriate function in these DLLs. Windows provides an application called "rundll32.exe" - located in Windows main directory - that allows you to do that. For example, to open the Mouse Properties dialog you should write this line in the Run dialog:

Click here to copy the following block
rundll32.exe shell32.dll,Control_RunDLL main.cpl @0

If you know the correct syntax, you can open these dialogs from your applications as well. here is a routine that can open most of the Control Panel dialogs. It takes a value specified in a Enum list and uses it to determine the correct string to pass to "rundll32.exe", then passes the full commnad line to the Shell function:

Click here to copy the following block
Public Enum mbDialogType
  mbNewHardware
  mbAddRemove
  mbDateTimeProp
  mbDisplayProp
  mbInternetProp
  mbGameProp
  mbKeyboardProp
  mbModemProp
  mbMouseProp
  mbMultimediaProp
  mbNetworkProp
  mbPasswordProp
  mbInternationalProp
  mbSoundProp
  mbSystemProp
End Enum
    
Sub OpenWindowsDialog(ByVal mbDialog As mbDialogType)
  Dim s As String
  Select Case mbDialog
    Case mbNewHardware: s = "sysdm.cpl @1"
    Case mbAddRemove: s = "appwiz.cpl,,1"
    Case mbDateTimeProp: s = "timedate.cpl"
    Case mbDisplayProp: s = "desk.cpl,,0"
    Case mbInternetProp: s = "inetcpl.cpl,,0"
    Case mbGameProp: s = "joy.cpl"
    Case mbKeyboardProp: s = "main.cpl @1"
    Case mbModemProp: s = "modem.cpl"
    Case mbMouseProp: s = "main.cpl @0"
    Case mbMultimediaProp: s = "mmsys.cpl,,0"
    Case mbNetworkProp: s = "netcpl.cpl"
    Case mbPasswordProp: s = "password.cpl"
    Case mbInternationalProp: s = "intl.cpl,,0"
    Case mbSoundProp: s = "mmsys.cpl @1"
    Case mbSystemProp: s = "sysdm.cpl,,0"
  End Select
  Shell "rundll32.exe shell32.dll,Control_RunDLL " & s, 5
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.