Enumerating Control Panel applets
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Enumerating Control Panel applets

  1. #1
    Join Date
    Feb 2001
    Location
    AZ
    Posts
    201

    Enumerating Control Panel applets

    I am trying to enumerate the control panel applets. I have seen MSDN article Q232536 and have incorporated it's code in my program. On Windows NT 4.0 it enumerates all the applets, on Windows 2000 it omits about 4 of them.

    Thanks in advance,
    Hal


    Here is the code I am using:

    char szSystemFolder[MAX_PATH];
    HANDLE hFile;
    WIN32_FIND_DATA fdName;
    CString strAppName;

    // Get the location of the Control Panel applets.
    GetSystemDirectory(szSystemFolder, sizeof(szSystemFolder));
    SetCurrentDirectory(szSystemFolder);


    // Process the first DLL.
    hFile = FindFirstFile(_T("*.cpl"), &fdName);
    GetApplet(fdName.cFileName, &strAppName);

    // Process the remaining DLLs
    while (FindNextFile(hFile, &fdName))
    {
    GetApplet(fdName.cFileName, &strAppName);
    }


    void CCPManDlg::GetApplet(char* szDllName, CString* strAppName)
    {
    union
    {
    NEWCPLINFOA NewCplInfoA;
    NEWCPLINFOW NewCplInfoW;
    } Newcpl;

    HINSTANCE hLib;
    APPLET_PROC CplCall;
    LONG i;
    CString str;
    int nAppIndex = 0;
    CAppletInfo* pAppletInfo;


    int n = sizeof(NEWCPLINFOA);
    int m = sizeof(NEWCPLINFOW);

    if (!(hLib = LoadLibrary(szDllName)))
    return;
    if (!(CplCall=(APPLET_PROC)GetProcAddress(hLib,"CPlApplet")))
    {
    FreeLibrary(hLib);
    return;
    }


    CplCall(NULL, CPL_INIT,0,0);

    for (i = 0; i < CplCall(NULL,CPL_GETCOUNT,0,0); i++)
    {
    Newcpl.NewCplInfoA.dwSize = 0;
    Newcpl.NewCplInfoA.dwFlags = 0;
    CplCall(NULL,CPL_NEWINQUIRE,i,(long)&Newcpl);

    if (Newcpl.NewCplInfoA.dwSize != sizeof(NEWCPLINFOA))
    {
    CPLINFO CInfo;

    CplCall(NULL,CPL_INQUIRE,i,(long)&CInfo);
    LoadStringA(hLib,CInfo.idName,
    Newcpl.NewCplInfoA.szName,32);
    if ( Newcpl.NewCplInfoA.dwSize == 0 )
    Newcpl.NewCplInfoA.hIcon = LoadIcon(hLib, MAKEINTRESOURCE(CInfo.idIcon));
    }
    pAppletInfo = new CAppletInfo;
    if ( !m_pAppletInfo )
    {
    m_pAppletInfo = pAppletInfo;
    m_pPrevAppletInfo = m_pAppletInfo;
    }
    else
    {
    m_pPrevAppletInfo->m_paiNext = pAppletInfo;
    m_pPrevAppletInfo = pAppletInfo;
    }
    m_ilIcons.Add(Newcpl.NewCplInfoA.hIcon);
    str.Format("%s", Newcpl.NewCplInfoA.szName);
    str.Remove('&');
    pAppletInfo->m_strAppName = str;
    pAppletInfo->m_strDllName = szDllName;
    pAppletInfo->m_dwAppIndex = nAppIndex;
    pAppletInfo->m_dwIconIndex = m_nIconCount;
    pAppletInfo->m_strAppStatus = "N";
    ++m_nIconCount;
    ++nAppIndex;
    }
    return;
    }

    up·grade (up'gräd'),
    to take out old bugs
    and put in new ones.

  2. #2
    Join Date
    Feb 2001
    Location
    England
    Posts
    51

    Re: Enumerating Control Panel applets

    you should check to see if these control panel
    files exist.

    asthe following are Folder References.

    Administrative Tools
    Fonts
    Printers
    Network and Dialup Connections
    Scheduled Tasks.

    you can check this by right clicking on each icon if you can explore its not a CPL File!!..


    Bye
    hope this helps

    CPP is Fun.
    MFC Gives Headaches.




  3. #3
    Join Date
    Feb 2001
    Location
    AZ
    Posts
    201

    Re: Enumerating Control Panel applets

    Those are the exact ones I am missing. Is there a way to get access to them programatically?

    Thanks,
    Hal

    up·grade (up'gräd'),
    to take out old bugs
    and put in new ones.

  4. #4
    Join Date
    Feb 2001
    Location
    England
    Posts
    51

    Re: Enumerating Control Panel applets

    You could possibly do this via the registry for the look under this key for access to
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer
    if you look under this key location you will
    see sub keys with the values you require to access these area's

    you could also use the rundll to open the required area.
    to install a printer, etc..




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center