none
Opening Control Panel applet RRS feed

  • Question

  • Below is some code to open the control panel or one of its applets.  TCError() is a wrapper for FormatMessage().

    When (*szArg == 0) it will open the control panel on both Windows 7 and Windows 10.  When (*szArg != 0) and szItemName is a valid name (e.g., L"Microsoft.System") it will open the applet on Windows 7.  On Windows 10, IOpenControlPanel::Open fails with ERROR_ACCESS_DENIED.  I am an administrator on both test machines.

    What's up?  Thanks.  [I would have started in a Win10 or security forum, but my own code is the only way I can produce the problem.]

    CoInitialize(NULL);
    IOpenControlPanel *pPanel = NULL; 
    HRESULT hr = CoCreateInstance(CLSID_OpenControlPanel, NULL, CLSCTX_INPROC_SERVER, IID_IOpenControlPanel, (LPVOID*) &pPanel);
    if ( SUCCEEDED(hr) )
    {
    	hr = pPanel->Open(*szArg == 0 ? NULL : szItemName, NULL, NULL);
    	if ( hr != S_OK )
    	{
    		TCError(hr & 0xFFFF, L"IOpenControlPanel::Open");
    	}
    	pPanel->Release();
    }
    CoUninitialize();
    

    Thursday, September 20, 2018 5:17 PM

All replies

  • For what its worth, the canonical name Microsoft.System is not shown as supported on Win 10 according to https://docs.microsoft.com/en-us/windows/desktop/shell/controlpanel-canonical-names#system

    System

    • Canonical name: Microsoft.System
      • GUID: {BB06C0E4-D293-4f75-8A90-CB05B6477EEE}
      • Supported OS: Windows Vista, Windows 7, Windows 8, Windows 8.1
    • Module name: @%SystemRoot%\System32\systemcpl.dll,-1


    Thursday, September 20, 2018 5:38 PM
  • Is this by chance 32-bit code on 64-bit system?

    --pa

    Thursday, September 20, 2018 5:51 PM
  • Nothing on that page mentions Windows 10.

    When I dig the canonical names out of the registry (HKLM\...\CP\namespace\CLSID ... HKCR\CLSID\System.ApplicationName) I get all the expected ones (including "Microsoft.System").

    On Windows 10, the command line "control /name Microsoft.System" works.


    • Edited by v fatica Thursday, September 20, 2018 6:26 PM
    Thursday, September 20, 2018 6:20 PM
  • No, it is not.
    Thursday, September 20, 2018 6:21 PM
  • I did some tests on Windows 10 - 1803, 17134.285

    and it works normally for me (even not admin)

    IOpenControlPanel *pPanel;
    HRESULT hr = CoCreateInstance(CLSID_OpenControlPanel, NULL, CLSCTX_INPROC_SERVER, IID_IOpenControlPanel, (LPVOID*)&pPanel);
    if (SUCCEEDED(hr))
    {
    	// hr = pPanel->Open(L"Microsoft.ProgramsAndFeatures", NULL, NULL);
    	hr = pPanel->Open(L"Microsoft.System", NULL, NULL);
    	pPanel->Release();				
    }





    • Edited by Castorix31 Thursday, September 20, 2018 6:34 PM
    Thursday, September 20, 2018 6:30 PM
  • No surprise there. MS documentation has been known to be incorrect or incomplete in many cases.  Thus the mention of FWIW in my comment. :)
    Thursday, September 20, 2018 6:30 PM
  • Castorix31, I tried your code (verbatim) three ways ... my original project (a DLL plugin for the TCC shell from JPSoft), in a stand-alone subsystem console test exe, and in a stand-alone subsystem windows test exe ... all x64.

    None worked.

    FWIW, I'm using VS2010.

    Thursday, September 20, 2018 7:01 PM
  • Hi,

    >>Castorix31, I tried your code (verbatim) three ways ... my original project (a DLL plugin for the TCC shell from JPSoft), in a stand-alone subsystem console test exe, and in a stand-alone subsystem windows test exe ... all x64.

    I have tested the IOpenControlPanel::Open in vs2017 by using your code,seems that it works well.I suggest you download vs2017 and test your code.

    If it not work in vs2017, runing your stand-alone subsystem console test exe by running as Administrator (right-click your mouse), if it works well, then you could use LogonUser to get admin permission temporarily before you call the IOpenControlPanel::Open. 

    Or you could try checking your applets if they were registered well or not.More details

    Best Wishes,

    Jack Zhang


    MSDN Community Support<br/> Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact <a href="mailto:MSDNFSF@microsoft.com">MSDNFSF@microsoft.com</a>

    Friday, September 21, 2018 12:53 PM
    Moderator
  • I tested with VS 2015

    Does it fail with ShellExecute too ?

    like :

    ShellExecute(NULL, NULL, L"shell:::{BB06C0E4-D293-4f75-8A90-CB05B6477EEE}", NULL, NULL, SW_SHOWNORMAL);

    Friday, September 21, 2018 1:03 PM
  • ShellExecute(Ex) works.

    I was mistaken about the stand-alone tests.  They worked when I added CoInit it and CoUninit (doh!).

    I also put the code into another plugin (for JPSoft's TCC) DLL It failed there also.

    I didn't mention earlier that it fails similarly if I run it in TCC elevated.

    Since I also unravel the CLSID/canonical name relationship, I could easily rewrite it to use ShellExecuteEx.  Heck, I could even rewrite it to execute (for example) "control.exe /name Microsoft.System".  But I'm really curious about why my original way which works on Windows 7 fails on Windows 10.  It's quite a mystery!


    Friday, September 21, 2018 2:14 PM