212上位机VC MFC打开控制面板进行电脑设置
212上位机VC MFC打开控制面板进行电脑设置
功能展示
要设置电脑相关属性时我们要打开控件面板进行设置,例程实现调用控件面板内不同属性的设置窗口,如用例程可以进行鼠标设置,进行程序卸载,系统时间设置等等,要进行什么属性设置,点击例程对应按钮就可以,效果如图; 要点提示 我们例程通过控件面板的各个属性设置对话框程序的调用来进行相应电脑属性的设置,程序的调用例程中使用的函数是ShellExecute()当然读者还可以使用函数winexec()实现 ; 函数参数: ShellExecute( hWnd: HWND; {指定父窗口句柄} Operation: PChar; {指定动作, 譬如: open、runas、print、edit、explore、find[2] } FileName: PChar; {指定要打开的文件或程序} Parameters: PChar; {给要打开的程序指定参数; 如果打开的是文件这里应该是nil} Directory: PChar; {缺省目录}
ShowCmd: Integer) {打开选项} 实现功能 1.新建基于对话框的应用程序
2.拖拽几个按钮按钮对应调用不同的属性设置对话框如例程添加有<鼠标><键盘><<调制解调器><声音><日期和时间><显示><区域><添加新硬件><辅助选项>< Internet><系统><添加/删除程序>关联函数 - void CGkbc8Dlg::OnButton1()
- {
- //打开 IE4 的设置窗口
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL inetcpl.cpl",NULL,SW_SHOW);
- }
- void CGkbc8Dlg::OnButton3()
- {
- //启动日期和时间设置
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL timedate.cpl",NULL,SW_SHOW);
- }
- void CGkbc8Dlg::OnButton4()
- {
- //启动显示设置面板
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL desk.cpl",NULL,SW_SHOW);
- }
- void CGkbc8Dlg::OnButton5()
- {
- //启动辅助选项
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL access.cpl",NULL,SW_SHOW);
- }
- void CGkbc8Dlg::OnButton2()
- {
- //打开 声音的设置窗口
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL mmsys.cpl @1",NULL,SW_SHOW);
- }
复制代码- void CGkbc8Dlg::OnButton6()
- {
- //打开鼠标设置
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL main.cpl @0",NULL,SW_SHOW);
- }
- void CGkbc8Dlg::OnButton7() //键盘
- {
- //启动键盘设置
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL main.cpl @1",NULL,SW_SHOW);
- }
- void CGkbc8Dlg::OnButton12() //调制解调器
- {
- //启动调制解调器设置
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL modem.cpl",NULL,SW_SHOW);
- }
- void CGkbc8Dlg::OnButton10() //添加新硬件
- {
- //启动添加硬件设置
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL hdwwiz.cpl",NULL,SW_SHOW);
- }
- void CGkbc8Dlg::OnButton11() //系统
- {
- //打开系统设置
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL sysdm.cpl",NULL,SW_SHOW);
- }
- void CGkbc8Dlg::OnButton9() //添加/删除程序
- {
- //启动添加软件设置
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL appwiz.cpl",NULL,SW_SHOW);
- }
- void CGkbc8Dlg::OnButton8()
- {
- //打开区域设置
- ::ShellExecute(NULL,"OPEN","rundll32.exe","shell32.dll Control_RunDLL intl.cpl",NULL,SW_SHOW);
- }
复制代码
|