All windows control panel applets
this code lauches one of 18 windows control panel applets in my computer.each cpl is specified by its standard name.
can use two methods (shellexecute API with param or wscript object)-in principe all whose run with wscript.shell can also run with shellexecute with params.
1*control :Lauches the windows control panel
2*Control desktop:Launches the Desktop Control Panel subprogram
3*Control color :Launches the Desktop Control Panel subprogram, with the Appearance tab preselected
4*Control date/time :Launches the Date/Time Control Panel program
5*Control international:Launches the Regional Settings Control Panel subprogram
6*Control mouse :Launches the Mouse Control Panel subprogram
7*Control keyboard:Launches the Keyboard Control Panel subprogram
8*Control printers:Displays the Printers folder
9*Control fonts :Displays the Fonts folder
10*Control input.dll:Launches the Text Services and Input Language settings Control Panel subprogram
11*Control folders:Launches the Folder Settings Control Panel subprogram
12*Control netware :Launches the Novell NetWare Control Panel subprogram (if installed)
13*Control telephony:Launches the Phone and Modem Options Control Panel subprogram
14*Control admintools:Displays the Administrative Tools folder
15*Control schedtasks :Displays the Scheduled Tasks folder
16*Control netconnections:Displays the Network and Dial-up Connections folder
17*Control infrared:Launches the Infrared Control Panel subprogram (if installed)
18*Control userpasswords:Launches the Users and Passwords Control Panel subprogram
-the second part (*2*) presents another method to detect all cpl files in system and show them.
-the 3th code presents some of the shell application capabilities.
Click on code to select [then copy] -click outside to deselect
*1*
publi yform
yform=newObject("ycpl")
yform.show
read events
retu
*
DEFINE CLASS ycpl AS form
BorderStyle = 0
Top = 1
Left = 17
Height = 32
Width = 779
ShowWindow = 2
Caption = "18 Control panel utilities (cpl)"
MaxButton = .F.
Name = "Form1"
ADD OBJECT combo1 AS combobox WITH ;
FontBold = .T., ;
FontSize = 10, ;
Height = 35, ;
Left = 0, ;
SpecialEffect = 2, ;
Style = 2, ;
Top = -1, ;
Width = 740, ;
ForeColor = RGB(128,0,64), ;
SelectedItemForeColor = RGB(128,0,64), ;
SelectedBackColor = RGB(183,183,255), ;
SelectedItemBackColor = RGB(164,255,164), ;
Name = "Combo1"
ADD OBJECT label1 AS label WITH ;
AutoSize = .T., ;
FontBold = .T., ;
FontSize = 16, ;
Caption = "?", ;
Height = 27, ;
Left = 748, ;
MousePointer = 15, ;
Top = 1, ;
Width = 15, ;
ForeColor = RGB(0,255,0), ;
Name = "Label1"
PROCEDURE Destroy
clea events
ENDPROC
PROCEDURE combo1.Click
local m.x
do case
case this.value=1
m.x="Control desktop"
case this.value=2
m.x="Control color"
case this.value=3
m.x="Control date/time"
case this.value=4
m.x="Control international"
case this.value=5
m.x="Control mouse"
case this.value=6
m.x="Control keyboard"
case this.value=7
m.x="Control printers"
case this.value=8
m.x="Control fonts"
case this.value=9
m.x="Control input.dll"
case this.value=10
m.x="Control folders"
case this.value=11
m.x="Control netware"
case this.value=12
m.x="Control telephony"
case this.value=13
m.x="Control admintools"
case this.value=14
m.x="Control schedtasks"
case this.value=15
m.x="Control netconnections"
case this.value=16
m.x="Control infrared"
case this.value=17
m.x="Control userpasswords"
case this.value=18
m.x="control"
endcase
&&shellexecute
DECLARE INTEGER ShellExecute IN SHELL32.DLL INTEGER nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow
result = ShellExecute(0, "open", "c:\windows\system32\cmd.exe ","/c "+m.x,"",0)
*another method with shell script
*local m.myvar
*text to m.myvar textmerge noshow
*c:\windows\system32\cmd.exe /c "<<m.x>>"
*endtext
*oshell=newObject("wscript.shell")
*oshell.run(m.myvar,0,.t.)
*oshell=null
retu
ENDPROC
PROCEDURE combo1.Init
with this
.additem("1.Control desktop Launches the Desktop Control Panel subprogram")
.additem("2.Control color Launches the Desktop Control Panel subprogram, with the Appearance tab preselected")
.additem("3.Control date/time Launches the Date/Time Control Panel program")
.additem("4.Control international Launches the Regional Settings Control Panel subprogram")
.additem("5.Control mouse Launches the Mouse Control Panel subprogram")
.additem("6.Control keyboard Launches the Keyboard Control Panel subprogram")
.additem("7.Control printers Displays the Printers folder")
.additem("8.Control fonts Displays the Fonts folder")
.additem("9.Control input.dll Launches the Text Services and Input Language settings Control Panel subprogram")
.additem("10.Control folders Launches the Folder Settings Control Panel subprogram")
.additem("11.Control netware Launches the Novell NetWare Control Panel subprogram (if installed)")
.additem("12.Control telephony Launches the Phone and Modem Options Control Panel subprogram")
.additem("13.Control admintools Displays the Administrative Tools folder")
.additem("14.Control schedtasks Displays the Scheduled Tasks folder")
.additem("15.Control netconnections Displays the Network and Dial-up Connections folder")
.additem("16.Control infrared Launches the Infrared Control Panel subprogram (if installed)")
.additem("17.Control userpasswords Launches the Users and Passwords Control Panel subprogram")
.additem("18.Control panel ")
.style=2
listindex=1
.value=1
endwith
ENDPROC
PROCEDURE label1.Click
local m.myvar
text to m.myvar noshow
this code lauches one of 18 windows control panel applets.each cpl is specified by its standard name.
can use two methods (shellecute with param or script object)
*control Lauches the windows control panel
*Control desktop Launches the Desktop Control Panel subprogram
*Control color Launches the Desktop Control Panel subprogram, with the Appearance tab preselected
*Control date/time Launches the Date/Time Control Panel program
*Control international Launches the Regional Settings Control Panel subprogram
*Control mouse Launches the Mouse Control Panel subprogram
*Control keyboard Launches the Keyboard Control Panel subprogram
*Control printers Displays the Printers folder
*Control fonts Displays the Fonts folder
*Control input.dll Launches the Text Services and Input Language settings Control Panel subprogram
*Control folders Launches the Folder Settings Control Panel subprogram
*Control netware Launches the Novell NetWare Control Panel subprogram (if installed)
*Control telephony Launches the Phone and Modem Options Control Panel subprogram
*Control admintools Displays the Administrative Tools folder
*Control schedtasks Displays the Scheduled Tasks folder
*Control netconnections Displays the Network and Dial-up Connections folder
*Control infrared Launches the Infrared Control Panel subprogram (if installed)
*Control userpasswords Launches the Users and Passwords Control Panel subprogram
endtext
messagebox(m.myvar,0+32+4096,"18 control panel utilities")
ENDPROC
ENDDEFINE
*
*-- EndDefine: ycpl
**************************************************
Click on code to select [then copy] -click outside to deselect
*2*
*searching for all cpl files in windows system32
Publi yform
yform=Newobject("ycpl")
yform.Show
Read Events
Retu
*
Define Class ycpl As Form
BorderStyle = 0
Top = 1
Left = 17
Height = 32
Width = 779
ShowWindow = 2
Caption = "18 Control panel utilities (cpl)"
MaxButton = .F.
Name = "Form1"
Add Object label2 As Label With ;
AutoSize = .T., ;
FontBold = .T., ;
FontSize = 20, ;
BackStyle = 0, ;
Caption = "?", ;
Height = 35, ;
Left = 747, ;
MousePointer = 15, ;
Top = 4, ;
Width = 19, ;
ForeColor = Rgb(192,192,192), ;
Name = "Label2"
Add Object combo1 As ComboBox With ;
FontBold = .T., ;
FontSize = 10, ;
Height = 35, ;
Left = 0, ;
SpecialEffect = 2, ;
Style = 2, ;
Top = -1, ;
Width = 740, ;
ForeColor = Rgb(128,0,64), ;
SelectedForeColor = Rgb(0,0,0), ;
SelectedItemForeColor = Rgb(0,0,0), ;
SelectedBackColor = Rgb(213,170,255), ;
SelectedItemBackColor = Rgb(164,255,164), ;
Name = "Combo1"
Add Object label1 As Label With ;
AutoSize = .T., ;
FontBold = .T., ;
FontSize = 20, ;
BackStyle = 0, ;
Caption = "?", ;
Height = 35, ;
Left = 745, ;
MousePointer = 15, ;
Top = 0, ;
Width = 19, ;
ForeColor = Rgb(0,255,0), ;
Name = "Label1"
Procedure Destroy
Clea Events
Endproc
Procedure Init
Local gnbre,m.yrep
m.yrep=Addbs(Getenv('windir')+"\system32")
gnbre=Adir(gabase,m.yrep+"*.cpl")
Create Cursor ycurs (ycpl c(40))
For i=1 To gnbre
Insert Into ycurs Values (m.yrep+gabase(i,1))
Endfor
Sele ycurs
*brow title trans(reccount())+" cpl ."
Locate
With Thisform.combo1
.AddItem("control.exe")
Sele ycurs
Scan
.AddItem(ycpl)
Endscan
.Style=2
.ListIndex=1
Endwith
Thisform.Caption=Trans(Reccount())+" control panel applets in "+Addbs(Getenv('windir'))+"system32"
Endproc
Procedure combo1.Click
Local m.myvar,m.appl
If Lower(Allt(This.Value))=="control.exe"
m.myvar="control.exe"
Else
TEXT to m.myvar textmerge noshow
control.exe "<<allt(this.value)>>"
ENDTEXT
Endi
Messagebox(m.myvar,0+32+4096,'' , 1000)
*!**first method with shell script-uncomment to run this method
*!*Local oshell
*!*oshell=Createobject("WScript.Shell")
*!*try
*!*oshell.Run(m.myvar)
*!*catch
*!*messagebox("An error was occured.",16+4096,"error",1000)
*!*endtry
*!*oshell=Null
*!*retu
***************************
*second method with shellexecute
If This.Value="control.exe"
m.appl=""
Else
m.appl=This.Value
Endi
Declare Integer ShellExecute In SHELL32.Dll Integer nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow
result=ShellExecute(0,"open","control.exe",m.appl,"",1)
Retu
Endproc
Procedure combo1.Init
Endproc
Procedure label1.Click
Local m.myvar
TEXT to m.myvar noshow
this code launches one of windows control panel applets.
it gathers all cpl files in the windows\system32 folder .
2 methods can be used:
1.shell scripting with createObject("wscript.shell"
2.shellexecute API method with param.
Certain cpl files dont comes as system files.
if you see anything,the functionality is not installed (hardware absent..)
ENDTEXT
Messagebox(m.myvar,0+32+4096,"Control panel applets")
Endproc
Enddefine
*
*-- EndDefine: ycpl
Click on code to select [then copy] -click outside to deselect
*3*
*Shell application capabilities
Clea All
yform=Createobject("asup")
yform.Show
Read Events
Return
Define Class asup As Form
Top = 15
Left = 44
Height = 368
Width = 365
ShowWindow = 2
DoCreate = .T.
ShowTips = .T.
Caption = "Shell application"
MaxButton = .F.
KeyPreview = .T.
Name = "Form1"
Add Object command1 As CommandButton With ;
Top = 96, ;
Left = 24, ;
Height = 27, ;
Width = 290, ;
Caption = "Minimizes all windows on the desktop", ;
Name = "Command1"
Add Object command2 As CommandButton With ;
Top = 125, ;
Left = 24, ;
Height = 27, ;
Width = 290, ;
Caption = "Displays the Run dialog box", ;
Name = "Command2"
Add Object command3 As CommandButton With ;
Top = 155, ;
Left = 24, ;
Height = 27, ;
Width = 290, ;
Caption = "Displays the Shut Down Windows dialog box", ;
Name = "Command3"
Add Object command4 As CommandButton With ;
Top = 184, ;
Left = 24, ;
Height = 27, ;
Width = 290, ;
Caption = "Displays the Date/Time dialog box", ;
Name = "Command4"
Add Object command6 As CommandButton With ;
Top = 211, ;
Left = 24, ;
Height = 27, ;
Width = 290, ;
Caption = "Displays the Internet Properties dialog box", ;
Name = "Command6"
Add Object command7 As CommandButton With ;
Top = 240, ;
Left = 24, ;
Height = 27, ;
Width = 290, ;
Caption = "Explores any folder", ;
Name = "Command7"
Add Object command8 As CommandButton With ;
Top = 270, ;
Left = 24, ;
Height = 27, ;
Width = 290, ;
Caption = "Enables user to select folder from Program Files", ;
Name = "Command8"
Add Object command10 As CommandButton With ;
Top = 304, ;
Left = 24, ;
Height = 27, ;
Width = 290, ;
Caption = "Displays the Taskbar Properties dialog box", ;
Name = "Command10"
Add Object label2 As Label With ;
FontSize = 20, ;
Caption = "Shell.application samples", ;
Height = 61, ;
Left = 17-3, ;
Top = 24-3 , ;
Width = 324, ;
fontbold=.T.,;
autosize=.T.,;
ForeColor = Rgb(20,22,20), ;
Name = "Label2"
Add Object label1 As Label With ;
FontSize = 20, ;
Caption = "Shell.application samples", ;
Height = 61, ;
Left = 17, ;
Top = 24, ;
Width = 324, ;
backstyle=0,;
fontbold=.T.,;
autosize=.T.,;
ForeColor = Rgb(0,255,0), ;
Name = "Label1"
Procedure Click
* 'Displays the Taskbar Properties dialog box
oShell.TrayProperties
Endproc
Procedure Destroy
_Screen.WindowState=0
oShell=Null
Clea Events
Endproc
Procedure Init
_Screen.WindowState=1
Thisform.label2.ZOrder(1)
Publi oShell
oShell=Createobject("shell.application")
Endproc
Procedure command1.Click
*Minimizes all windows on the desktop
oShell.MinimizeAll && can also use oshell.toggleDesktop()
Endproc
Procedure command2.Click
*Displays the Run dialog box
oShell.FileRun
Endproc
Procedure command3.Click
*Displays the Shut Down Windows dialog box
oShell.ShutdownWindows
Endproc
Procedure command4.Click
*Displays the Date/Time dialog box
oShell.SetTime
Endproc
Procedure command6.Click
*Displays the Internet Properties dialog box
oShell.ControlPanelItem ("INETCPL.cpl")
Endproc
Procedure command7.Click
lcFolder=Getdir()
*Explores any folder
oShell.Explore( lcFolder) &&syntax depends of language used
Endproc
Procedure command8.Click
*Enables user to select folder from Program Files
oShell.BrowseForFolder(0, "My Programs", 0, "C:\Program Files")
Endproc
Procedure command10.Click
*Displays the Taskbar Properties dialog box
oShell.TrayProperties
Endproc
Enddefine
*
Click on code to select [then copy] -click outside to deselect
*4*
*this code fires a panel control to modify interactively the win10 theme colors (directly in the cpl window opened)
*The win10 colors list is still a bit limited compared to the Color and Appearance options in Windows 8.1, which
*allowed you to select any color you liked.
*This desktop control panel has been completely hidden in Windows 10. However, you can still access it — for now
* (warning to win10 updates)
*To access this hidden control panel, and run the command code follow
*test successfully on wndows10 version 10240
*added to aeroglass it provides superb colring themes
*here 3 similar codes to fire this colors cpl
*option 1
&&shellexecute
DECLARE INTEGER ShellExecute IN SHELL32.DLL INTEGER nWinHandle,;
STRING cOperation,;
STRING cFileName,;
STRING cParameters,;
STRING cDirectory,;
INTEGER nShowWindow
result = ShellExecute(0, "open", "rundll32.exe ","shell32.dll Control_RunDLL desk.cpl,Advanced,@Advanced","",1)
*****
if result<=32
messagebox(trans(result)+"....an error was occured!",0+32+4096) &&here 42 ok
endi
*!* *option 2
*!* local oshell
*!* oshell=newObject("wscript.shell")
*!* oshell.run("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,Advanced,@Advanced",0,.t.)
*!* oshel=null
*!* *option3
*!* * it can be done also with this code
*!* DECLARE INTEGER ShellExecute IN SHELL32.DLL INTEGER nWinHandle,;
*!* STRING cOperation,;
*!* STRING cFileName,;
*!* STRING cParameters,;
*!* STRING cDirectory,;
*!* INTEGER nShowWindow
*!* m.x="control color"
*!* result = ShellExecute(0, "open", "c:\windows\system32\cmd.exe ","/c "+m.x,"",0)
*!* *note can also change it by twiking the registry:http://www.thewindowsclub.com/get-colored-window-title-bar-windows-10
this window is hidden in windows10 and can be (actually) obtained only with code(warning to updates).
*Important:*the code above is tested on visual foxpro 9 sp2-under windows 10 pro