ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

CPlApplet* Control_LoadApplet ( HWND  hWnd,
LPCWSTR  cmd,
CPanel panel 
)

Definition at line 45 of file control.cpp.

Referenced by Control_DoLaunch(), Control_DoWindow(), and CControlPanelEnum::RegisterCPanelApp().

{
    CPlApplet*    applet;
    unsigned     i;
    CPLINFO    info;
    NEWCPLINFOW newinfo;

    if (!(applet = (CPlApplet *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*applet))))
       return applet;

    applet->hWnd = hWnd;

    if (!(applet->hModule = LoadLibraryW(cmd)))
    {
        WARN("Cannot load control panel applet %s\n", debugstr_w(cmd));
        goto theError;
    }
    if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule, "CPlApplet")))
    {
        WARN("Not a valid control panel applet %s\n", debugstr_w(cmd));
        goto theError;
    }
    if (!applet->proc(hWnd, CPL_INIT, 0L, 0L))
    {
        WARN("Init of applet has failed\n");
        goto theError;
    }
    if ((applet->count = applet->proc(hWnd, CPL_GETCOUNT, 0L, 0L)) == 0)
    {
        WARN("No subprogram in applet\n");
        goto theError;
    }

    applet = (CPlApplet *)HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet,
             sizeof(*applet) + (applet->count - 1) * sizeof(NEWCPLINFOW));

    for (i = 0; i < applet->count; i++)
    {
        ZeroMemory(&newinfo, sizeof(newinfo));
        newinfo.dwSize = sizeof(NEWCPLINFOW);
        applet->info[i].dwSize = sizeof(NEWCPLINFOW);
       /* proc is supposed to return a null value upon success for
    * CPL_INQUIRE and CPL_NEWINQUIRE
    * However, real drivers don't seem to behave like this
    * So, use introspection rather than return value
    */
        applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo);
        if (newinfo.hIcon == 0)
        {
            applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info);
            if (info.idIcon == 0 || info.idName == 0)
            {
                WARN("Couldn't get info from sp %u\n", i);
                applet->info[i].dwSize = 0;
            }
            else
            {
                /* convert the old data into the new structure */
                applet->info[i].dwFlags = 0;
                applet->info[i].dwHelpContext = 0;
                applet->info[i].lData = info.lData;
                applet->info[i].hIcon = LoadIconW(applet->hModule,
                                MAKEINTRESOURCEW(info.idIcon));
                LoadStringW(applet->hModule, info.idName,
                    applet->info[i].szName, sizeof(applet->info[i].szName) / sizeof(WCHAR));
                LoadStringW(applet->hModule, info.idInfo,
                    applet->info[i].szInfo, sizeof(applet->info[i].szInfo) / sizeof(WCHAR));
                applet->info[i].szHelpFile[0] = '\0';
            }
        }
        else
        {
            CopyMemory(&applet->info[i], &newinfo, newinfo.dwSize);
            if (newinfo.dwSize != sizeof(NEWCPLINFOW))
            {
                applet->info[i].dwSize = sizeof(NEWCPLINFOW);
                lstrcpyW(applet->info[i].szName, newinfo.szName);
                lstrcpyW(applet->info[i].szInfo, newinfo.szInfo);
                lstrcpyW(applet->info[i].szHelpFile, newinfo.szHelpFile);
            }
        }
    }

    applet->next = panel->first;
    panel->first = applet;

    return applet;

 theError:
    Control_UnloadApplet(applet);
    return NULL;
}

Generated on Sun May 27 2012 05:18:14 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.