Author Topic: Control_Rundll  (Read 361 times)

airr

  • Sr. Member
  • ****
  • Posts: 252
    • View Profile
Control_Rundll
« on: October 23, 2024, 11:01:26 PM »
Years ago, MrB posted several items to the old Yahoo mailing list regarding opening control panel items using BCX.

They basically consisted of items like:

Code: [Select]
Shell "rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl"
I wondered if there was a way to call "Control_RunDLL" directly from shell32.dll, so here's my approach:

Code: [Select]
Declare Sub Control_RunDLL lib "shell32.dll" Alias "Control_RunDLL"(hwnd As HWND, hinstance As HINSTANCE, Panel As String, item As Int)

Function WinMain()
    Control_RunDLL(Null, Null, "appwiz.cpl", 0)
    Return 0
End Function

I'm using WinMain so you don't get the momentary console showing, so you'll need to compile this as a GUI app.

Not really useful, was more of a mental exercise on my part...and BCX makes it dead simple.....

AIR.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2392
    • View Profile
Re: Control_Rundll
« Reply #1 on: October 23, 2024, 11:39:15 PM »
Here you go ... compiles and runs. 

Just click CANCEL when the applets popup

Code: [Select]

' ------------------------------------------------------------------------
' This library of wrappers calls most of your Control Panel Apps
' The wrappers that take one parameter support indexed sub-functions
' This was derived from a RapidQ library that I found -- thanks for that!
' -----------------------------------------------------------------------

OpenMouseDlg             (0)
OpenKeyboardDlg          (0)
OpenDisplayDlg           (0)
OpenDialingDlg           (0)
OpenSystemDialog         (0)
OpenScannerDlg           (0)
OpenAddRemoveProgramsDlg (0)
OpenPowerMgmtDlg         (0)
OpenPasswordsDlg         (0)
OpenModemDlg             (0)
OpenMMDeviceDlg          (0)
OpenGamesDlg             (0)
OpenRegionalDlg          (0)
OpenInternetDlg          (0)
OpenUsersDlg             (0)

OpenPrintersFolder       ()
OpenFontsFolder          ()
OpenTimeDlg              ()
OpenAddNewHardwareDlg    ()
OpenThemesDlg            ()
OpenSoundsDlg            ()
OpenTweakUIDlg           ()

'----------------------------------------- A little helper function
FUNCTION   TrimStr$(Index)
    FUNCTION = TRIM$(STR$(Index))
END FUNCTION
'-----------------------------------------


SUB OpenMouseDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL main.cpl @0," & TrimStr$(Index)
END SUB

SUB OpenKeyboardDlg(Index)
    IF Index>1 THEN Index = 0
    SHELL "rundll32.exe shell32.dll,Control_RunDLL main.cpl @1," & TrimStr$(Index)
END SUB

SUB OpenPrintersFolder
    SHELL "rundll32.exe shell32.dll,Control_RunDLL main.cpl @2"
END SUB

SUB OpenFontsFolder
    SHELL "rundll32.exe shell32.dll,Control_RunDLL main.cpl @3"
END SUB

SUB OpenDisplayDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL desk.cpl @0," & TrimStr$(Index)
END SUB

SUB OpenTimeDlg
    SHELL "rundll32.exe shell32.dll,Control_RunDLL timedate.cpl @0"
END SUB

SUB OpenDialingDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL telephon.cpl @0," & _
    TrimStr$(Index)
END SUB

SUB OpenSystemDialog(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl @0" & TrimStr$(Index)
END SUB

SUB OpenAddNewHardwareDlg
    SHELL "rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl @1"
END SUB

SUB OpenScannerDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL sticpl.cpl @0"
END SUB

SUB OpenThemesDlg
    SHELL "rundll32.exe shell32.dll,Control_RunDLL themes.cpl @0"
END SUB

SUB OpenAddRemoveProgramsDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl @0," & TrimStr$(Index)
END SUB

SUB OpenPowerMgmtDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL powercfg.cpl @0," & _
    TrimStr$(Index)
END SUB

SUB OpenPasswordsDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL password.cpl @0," & _
    TrimStr$(Index)
END SUB

SUB OpenModemDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL modem.cpl @0," & TrimStr$(Index)
END SUB

SUB OpenMMDeviceDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl @0," & TrimStr$(Index)
END SUB

SUB OpenSoundsDlg
    SHELL "rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl @1"
END SUB

SUB OpenGamesDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL joy.cpl @0," & TrimStr$(Index)
END SUB

SUB OpenRegionalDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL intl.cpl @0," &  TrimStr$(Index)
END SUB

SUB OpenInternetDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl @0," & _
    TrimStr$(Index)
END SUB

SUB OpenUsersDlg(Index)
    SHELL "rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl @1,"  & _
    TrimStr$(Index)
END SUB

SUB OpenTweakUIDlg
    SHELL "rundll32.exe shell32.dll,Control_RunDLL tweakui.cpl @0"
END SUB



airr

  • Sr. Member
  • ****
  • Posts: 252
    • View Profile
Re: Control_Rundll
« Reply #2 on: October 24, 2024, 01:16:01 AM »
Yeah, the direct call to Control_RunDLL isn't stable.

But using SHELL, you can call most of the cpl files directly.  Here's a short example:

Code: [Select]
Function Main()
    OpenMouseDlg             (0)
    OpenKeyboardDlg          (0)
    OpenDisplayDlg           (0)
    OpenDialingDlg           (0)
    OpenSystemDialog         (0)
End Function


SUB OpenMouseDlg(Index)
    shell "main.cpl @0," & TrimStr$(Index)
END SUB

SUB OpenKeyboardDlg(Index)
    IF Index>1 THEN Index = 0
    SHELL "main.cpl @1," & TrimStr$(Index)
END SUB

SUB OpenDisplayDlg(Index)
    SHELL "desk.cpl @0," & TrimStr$(Index)
END SUB

SUB OpenDialingDlg(Index)
    SHELL "telephon.cpl @0," & TrimStr$(Index)
END SUB

SUB OpenSystemDialog(Index)
    SHELL "sysdm.cpl @0" & TrimStr$(Index)
END SUB


FUNCTION   TrimStr$(Index)
    FUNCTION = TRIM$(STR$(Index))
END FUNCTION

AIR.