When an application is running, it sometimes requires special requirements for the system environment. For example, in a Delphi database application, you may need to set the BDE (Borland Database Engine) or ODBC data source name (DSN: Data Source Name); in a network application, you may need to set the network configuration settings, Modem property settings or user dial-up. The connection account and password are set and saved in the system; in CTI (Computer-Telephony Integration) application may need to set the phone dialing properties; in the game program may need to set the multimedia or game controller; etc. At this time, you need to change the environment settings of the Windows system to adapt to the requirements for the normal operation of the application. When the application cannot set up the environment on its own, the software user may be required to participate and assist in completing the setup.
Most system settings of Win9X/NT are performed in the control panel. We can ask the user to open the control panel themselves and find the corresponding items to set up. At this time, the user is required to be familiar with the control panel. We can also automatically open the control panel for the user in the program and select the corresponding items. At this time, all the user has to do is to make settings. set up. The latter method is undoubtedly more friendly and can improve the user's work efficiency.
Most of the project settings in the control panel correspond to a CPL file in the System directory of Windows. For example, the file corresponding to the "Internet" attribute is InetCpl.cpl, the file corresponding to the "Multimedia" attribute is MmSys.cpl, etc. By calling these files, the corresponding property setting window can be opened, and you can even jump to the corresponding property page such as the "Connection" property page of the "Internet" property, effectively reducing the operating steps for software users.
The calling format of the CPL file is "RunDLL32.exe Shell32.dll,Control_RunDLL CPLFile.cpl,,ItemNo" (see the default value of HKEY_CLASSES_ROOTcplfileshellcpopencommand in the registry), where CPLFile.cpl is the CPL file and ItemNo is the item number. In a Delphi program, you can use the WinExec or CreatePRocess function to call the CPL file, thereby calling the setting items of the control panel. If you want to call the "Connection" property page of the "Internet" property to set the account and password for a dial-up connection, you can use the statement "WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL InetCpl.cpl,,3',," SW_SHOWNORMAL);"; To solve the interpretation of two-digit year input in the 2000 problem, you need to call the "Date" property page of "Regional Settings", you can use the statement: "WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Intl.cpl, ,4',, SW_SHOWNORMAL);".
The list of statements corresponding to the setting calls of each item in the control panel is as follows:
//Open control panel
WinExec('RunDLL.exe Shell32.DLL,Control_RunDLL',SW_SHOWNORMAL);
//32-bit ODBC data source manager, ODBC data source, ODBC driver settings
//No parameters are provided to distinguish the six property pages of "User DSN", "System DSN", "File DSN", "ODBC Driver", "Tracking" and "About"
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL ODBCCP32.CPL',SW_SHOWNORMAL);
//BDE Administrator
//No parameters are provided to distinguish between the two property pages of "Databases" and "Configuration"
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL BdeAdmin.CPL',SW_SHOWNORMAL);
//Internet attribute, can have ItemNo parameter
//"General" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL InetCpl.cpl,,0', SW_SHOWNORMAL);
//"Security" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL InetCpl.cpl,,1', SW_SHOWNORMAL);
//"Content" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL InetCpl.cpl,,2', SW_SHOWNORMAL);
//"Connection" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL InetCpl.cpl,,3', SW_SHOWNORMAL);
//"Program" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL InetCpl.cpl,,4', SW_SHOWNORMAL);
//"Advanced" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL InetCpl.cpl,,5', SW_SHOWNORMAL);
//Telephone dialing properties, no parameters are provided to distinguish between the two property pages of "My Location" and "Phone Voice Driver"
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Telephon.cpl', SW_SHOWNORMAL);
//Power management settings, no parameters are provided to distinguish the two property pages of "Power Plan" and "Advanced"
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL PowerCfg.cpl', SW_SHOWNORMAL);
//Modem settings, no parameters are provided to distinguish between the "General" and "Diagnostic" property pages
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Modem.cpl', SW_SHOWNORMAL);
//Multimedia settings, can have ItemNo parameter
//"Audio" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Mmsys.cpl,,0', SW_SHOWNORMAL);
//"Video" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Mmsys.cpl,,1', SW_SHOWNORMAL);
//"MIDI" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Mmsys.cpl,,2', SW_SHOWNORMAL);
//"CD Music" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Mmsys.cpl,,3', SW_SHOWNORMAL);
//"Device" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Mmsys.cpl,,4', SW_SHOWNORMAL);
//Auxiliary option settings, can have ItemNo parameter
//"Keyboard" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL access.cpl,,1',SW_SHOWNORMAL);
//"Sound" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL access.cpl,,2', SW_SHOWNORMAL);
//"Display" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL access.cpl,,3', SW_SHOWNORMAL);
//"Mouse" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL access.cpl,,4', SW_SHOWNORMAL);
//"General" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL access.cpl,,5', SW_SHOWNORMAL);
//Password setting, no parameters are provided to distinguish between the two property pages of "Change Password" and "Modify User Configuration"
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL PassWord.cpl', SW_SHOWNORMAL);
//Regional settings, can have ItemNo parameter
//"Regional Settings" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Intl.cpl,,0', SW_SHOWNORMAL);
//"Number" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Intl.cpl,,1', SW_SHOWNORMAL);
//"Currency" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Intl.cpl,,2', SW_SHOWNORMAL);
//"Time" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Intl.cpl,,3', SW_SHOWNORMAL);
//"Date" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Intl.cpl,,4', SW_SHOWNORMAL);
//Date/time setting, can have ItemNo parameter
//"Date and time" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL TimeDate.cpl,,0', SW_SHOWNORMAL);
//"Time Zone" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL TimeDate.cpl,,1', SW_SHOWNORMAL);
//Mouse settings, no parameters are provided to distinguish the three property pages of "Button", "Pointer" and "Move"
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Main.cpl', SW_SHOWNORMAL);
//Add/delete program settings, optional ItemNo parameter
//"Installation/Uninstallation" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL AppWiz.cpl,,1', SW_SHOWNORMAL);
//"Windows Installer" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL AppWiz.cpl,,2', SW_SHOWNORMAL);
//"Boot Disk" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL AppWiz.cpl,,3', SW_SHOWNORMAL);
//Network settings, no parameters are provided to distinguish the three property pages of "Configuration", "Identification" and "Access Control"
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL NetCpl.cpl', SW_SHOWNORMAL);
//System settings,
//"General" property page, can have ItemNo parameter
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL SysDm.cpl,,0', SW_SHOWNORMAL);
//"Device Manager" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL SysDm.cpl,,1', SW_SHOWNORMAL);
//"Hardware Profile" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL SysDm.cpl,,2', SW_SHOWNORMAL);
//"Performance" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL SysDm.cpl,,3', SW_SHOWNORMAL);
//Display settings, can have ItemNo parameter
//"Background" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL desk.cpl,,0', SW_SHOWNORMAL);
//"Screen saver" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL desk.cpl,,1', SW_SHOWNORMAL);
//"Appearance" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL desk.cpl,,2', SW_SHOWNORMAL);
//"Settings" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL desk.cpl,,3', SW_SHOWNORMAL);
//Game controller settings, can have ItemNo parameter
//"General" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Joy.cpl,,0', SW_SHOWNORMAL);
//"Advanced" property page
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL Joy.cpl,,1', SW_SHOWNORMAL);
//Scanner and digital camera settings, no parameters are provided to distinguish the two property pages of "Device" and "Recording Settings"
WinExec('RunDLL32.exe Shell32.dll,Control_RunDLL StiCpl.cpl', SW_SHOWNORMAL);
The above program was debugged and passed under PWIN98+DELPHI3.0.