2002-03-10 00:29:33 +01:00
|
|
|
/* Control Panel management
|
|
|
|
*
|
|
|
|
* Copyright 2001 Eric Pouech
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*/
|
2001-02-23 02:12:26 +01:00
|
|
|
|
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-02-23 02:12:26 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2001-02-23 02:12:26 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2008-07-02 19:08:42 +02:00
|
|
|
#include "winreg.h"
|
2003-12-03 05:44:52 +01:00
|
|
|
#include "wine/winbase16.h"
|
|
|
|
#include "wownt32.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-02-23 02:12:26 +01:00
|
|
|
#include "cpl.h"
|
2002-12-13 03:17:54 +01:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
#define NO_SHLWAPI_REG
|
|
|
|
#include "shlwapi.h"
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
#include "cpanel.h"
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shlctrl);
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
CPlApplet* Control_UnloadApplet(CPlApplet* applet)
|
2001-02-23 02:12:26 +01:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
CPlApplet* next;
|
|
|
|
|
|
|
|
for (i = 0; i < applet->count; i++) {
|
|
|
|
if (!applet->info[i].dwSize) continue;
|
|
|
|
applet->proc(applet->hWnd, CPL_STOP, i, applet->info[i].lData);
|
|
|
|
}
|
|
|
|
if (applet->proc) applet->proc(applet->hWnd, CPL_EXIT, 0L, 0L);
|
|
|
|
FreeLibrary(applet->hModule);
|
|
|
|
next = applet->next;
|
|
|
|
HeapFree(GetProcessHeap(), 0, applet);
|
|
|
|
return next;
|
|
|
|
}
|
|
|
|
|
2004-03-27 02:42:22 +01:00
|
|
|
CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
|
2001-02-23 02:12:26 +01:00
|
|
|
{
|
|
|
|
CPlApplet* applet;
|
|
|
|
unsigned i;
|
|
|
|
CPLINFO info;
|
2002-12-13 03:17:54 +01:00
|
|
|
NEWCPLINFOW newinfo;
|
2001-02-23 02:12:26 +01:00
|
|
|
|
|
|
|
if (!(applet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*applet))))
|
|
|
|
return applet;
|
|
|
|
|
|
|
|
applet->hWnd = hWnd;
|
|
|
|
|
2002-12-13 03:17:54 +01:00
|
|
|
if (!(applet->hModule = LoadLibraryW(cmd))) {
|
|
|
|
WARN("Cannot load control panel applet %s\n", debugstr_w(cmd));
|
2001-02-23 02:12:26 +01:00
|
|
|
goto theError;
|
|
|
|
}
|
|
|
|
if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule, "CPlApplet"))) {
|
2002-12-13 03:17:54 +01:00
|
|
|
WARN("Not a valid control panel applet %s\n", debugstr_w(cmd));
|
2001-02-23 02:12:26 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet,
|
2002-12-13 03:17:54 +01:00
|
|
|
sizeof(*applet) + (applet->count - 1) * sizeof(NEWCPLINFOW));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
for (i = 0; i < applet->count; i++) {
|
2002-12-13 03:17:54 +01:00
|
|
|
ZeroMemory(&newinfo, sizeof(newinfo));
|
|
|
|
newinfo.dwSize = sizeof(NEWCPLINFOA);
|
|
|
|
applet->info[i].dwSize = sizeof(NEWCPLINFOW);
|
2008-02-13 22:30:53 +01:00
|
|
|
applet->info[i].dwFlags = 0;
|
|
|
|
applet->info[i].dwHelpContext = 0;
|
|
|
|
applet->info[i].szHelpFile[0] = '\0';
|
2001-02-23 02:12:26 +01:00
|
|
|
/* 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
|
|
|
|
*/
|
2008-02-13 22:30:53 +01:00
|
|
|
applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info);
|
|
|
|
applet->info[i].lData = info.lData;
|
|
|
|
if (info.idIcon != CPL_DYNAMIC_RES)
|
|
|
|
applet->info[i].hIcon = LoadIconW(applet->hModule,
|
|
|
|
MAKEINTRESOURCEW(info.idIcon));
|
|
|
|
if (info.idName != CPL_DYNAMIC_RES)
|
|
|
|
LoadStringW(applet->hModule, info.idName,
|
|
|
|
applet->info[i].szName, sizeof(applet->info[i].szName) / sizeof(WCHAR));
|
|
|
|
if (info.idInfo != CPL_DYNAMIC_RES)
|
|
|
|
LoadStringW(applet->hModule, info.idInfo,
|
|
|
|
applet->info[i].szInfo, sizeof(applet->info[i].szInfo) / sizeof(WCHAR));
|
|
|
|
|
|
|
|
if ((info.idIcon == CPL_DYNAMIC_RES) || (info.idName == CPL_DYNAMIC_RES) ||
|
|
|
|
(info.idInfo == CPL_DYNAMIC_RES)) {
|
|
|
|
applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo);
|
|
|
|
|
|
|
|
applet->info[i].dwFlags = newinfo.dwFlags;
|
|
|
|
applet->info[i].dwHelpContext = newinfo.dwHelpContext;
|
|
|
|
applet->info[i].lData = newinfo.lData;
|
|
|
|
if (info.idIcon == CPL_DYNAMIC_RES) {
|
|
|
|
if (!newinfo.hIcon) WARN("couldn't get icon for applet %u\n", i);
|
|
|
|
applet->info[i].hIcon = newinfo.hIcon;
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
2008-02-13 22:30:53 +01:00
|
|
|
if (newinfo.dwSize == sizeof(NEWCPLINFOW)) {
|
|
|
|
if (info.idName == CPL_DYNAMIC_RES)
|
|
|
|
memcpy(applet->info[i].szName, newinfo.szName, sizeof(newinfo.szName));
|
|
|
|
if (info.idInfo == CPL_DYNAMIC_RES)
|
|
|
|
memcpy(applet->info[i].szInfo, newinfo.szInfo, sizeof(newinfo.szInfo));
|
|
|
|
memcpy(applet->info[i].szHelpFile, newinfo.szHelpFile, sizeof(newinfo.szHelpFile));
|
|
|
|
} else {
|
|
|
|
if (info.idName == CPL_DYNAMIC_RES)
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szName,
|
|
|
|
sizeof(((LPNEWCPLINFOA)&newinfo)->szName) / sizeof(CHAR),
|
|
|
|
applet->info[i].szName,
|
|
|
|
sizeof(applet->info[i].szName) / sizeof(WCHAR));
|
|
|
|
if (info.idInfo == CPL_DYNAMIC_RES)
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szInfo,
|
|
|
|
sizeof(((LPNEWCPLINFOA)&newinfo)->szInfo) / sizeof(CHAR),
|
|
|
|
applet->info[i].szInfo,
|
|
|
|
sizeof(applet->info[i].szInfo) / sizeof(WCHAR));
|
2002-12-13 03:17:54 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szHelpFile,
|
|
|
|
sizeof(((LPNEWCPLINFOA)&newinfo)->szHelpFile) / sizeof(CHAR),
|
|
|
|
applet->info[i].szHelpFile,
|
|
|
|
sizeof(applet->info[i].szHelpFile) / sizeof(WCHAR));
|
|
|
|
}
|
|
|
|
}
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
applet->next = panel->first;
|
|
|
|
panel->first = applet;
|
|
|
|
|
|
|
|
return applet;
|
|
|
|
|
|
|
|
theError:
|
|
|
|
Control_UnloadApplet(applet);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Control_WndProc_Create(HWND hWnd, const CREATESTRUCTA* cs)
|
|
|
|
{
|
|
|
|
CPanel* panel = (CPanel*)cs->lpCreateParams;
|
|
|
|
|
2005-09-02 13:32:17 +02:00
|
|
|
SetWindowLongPtrA(hWnd, 0, (LONG_PTR)panel);
|
2001-02-23 02:12:26 +01:00
|
|
|
panel->status = 0;
|
|
|
|
panel->hWnd = hWnd;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define XICON 32
|
|
|
|
#define XSTEP 128
|
|
|
|
#define YICON 32
|
|
|
|
#define YSTEP 64
|
|
|
|
|
2006-10-25 17:42:11 +02:00
|
|
|
static BOOL Control_Localize(const CPanel* panel, int cx, int cy,
|
2001-02-23 02:12:26 +01:00
|
|
|
CPlApplet** papplet, unsigned* psp)
|
|
|
|
{
|
|
|
|
unsigned i, x = (XSTEP-XICON)/2, y = 0;
|
|
|
|
CPlApplet* applet;
|
|
|
|
RECT rc;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
GetClientRect(panel->hWnd, &rc);
|
2004-07-12 21:50:56 +02:00
|
|
|
for (applet = panel->first; applet; applet = applet->next) {
|
2001-02-23 02:12:26 +01:00
|
|
|
for (i = 0; i < applet->count; i++) {
|
|
|
|
if (!applet->info[i].dwSize) continue;
|
|
|
|
if (x + XSTEP >= rc.right - rc.left) {
|
|
|
|
x = (XSTEP-XICON)/2;
|
|
|
|
y += YSTEP;
|
|
|
|
}
|
|
|
|
if (cx >= x && cx < x + XICON && cy >= y && cy < y + YSTEP) {
|
|
|
|
*papplet = applet;
|
|
|
|
*psp = i;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
x += XSTEP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT Control_WndProc_Paint(const CPanel* panel, WPARAM wParam)
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
RECT rc, txtRect;
|
|
|
|
unsigned i, x = 0, y = 0;
|
|
|
|
CPlApplet* applet;
|
|
|
|
HGDIOBJ hOldFont;
|
|
|
|
|
|
|
|
hdc = (wParam) ? (HDC)wParam : BeginPaint(panel->hWnd, &ps);
|
|
|
|
hOldFont = SelectObject(hdc, GetStockObject(ANSI_VAR_FONT));
|
|
|
|
GetClientRect(panel->hWnd, &rc);
|
2004-07-12 21:50:56 +02:00
|
|
|
for (applet = panel->first; applet; applet = applet->next) {
|
2001-02-23 02:12:26 +01:00
|
|
|
for (i = 0; i < applet->count; i++) {
|
|
|
|
if (x + XSTEP >= rc.right - rc.left) {
|
|
|
|
x = 0;
|
|
|
|
y += YSTEP;
|
|
|
|
}
|
|
|
|
if (!applet->info[i].dwSize) continue;
|
|
|
|
DrawIcon(hdc, x + (XSTEP-XICON)/2, y, applet->info[i].hIcon);
|
|
|
|
txtRect.left = x;
|
|
|
|
txtRect.right = x + XSTEP;
|
|
|
|
txtRect.top = y + YICON;
|
|
|
|
txtRect.bottom = y + YSTEP;
|
2002-12-13 03:17:54 +01:00
|
|
|
DrawTextW(hdc, applet->info[i].szName, -1, &txtRect,
|
2001-02-23 02:12:26 +01:00
|
|
|
DT_CENTER | DT_VCENTER);
|
|
|
|
x += XSTEP;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SelectObject(hdc, hOldFont);
|
|
|
|
if (!wParam) EndPaint(panel->hWnd, &ps);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT Control_WndProc_LButton(CPanel* panel, LPARAM lParam, BOOL up)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
CPlApplet* applet;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-10-25 17:42:11 +02:00
|
|
|
if (Control_Localize(panel, (short)LOWORD(lParam), (short)HIWORD(lParam), &applet, &i)) {
|
2001-02-23 02:12:26 +01:00
|
|
|
if (up) {
|
|
|
|
if (panel->clkApplet == applet && panel->clkSP == i) {
|
|
|
|
applet->proc(applet->hWnd, CPL_DBLCLK, i, applet->info[i].lData);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
panel->clkApplet = applet;
|
|
|
|
panel->clkSP = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg,
|
2001-02-23 02:12:26 +01:00
|
|
|
WPARAM lParam1, LPARAM lParam2)
|
|
|
|
{
|
2005-09-02 13:32:17 +02:00
|
|
|
CPanel* panel = (CPanel*)GetWindowLongPtrA(hWnd, 0);
|
2001-02-23 02:12:26 +01:00
|
|
|
|
|
|
|
if (panel || wMsg == WM_CREATE) {
|
|
|
|
switch (wMsg) {
|
|
|
|
case WM_CREATE:
|
|
|
|
Control_WndProc_Create(hWnd, (CREATESTRUCTA*)lParam2);
|
|
|
|
return 0;
|
|
|
|
case WM_DESTROY:
|
2003-12-11 05:24:16 +01:00
|
|
|
{
|
|
|
|
CPlApplet* applet = panel->first;
|
|
|
|
while (applet)
|
|
|
|
applet = Control_UnloadApplet(applet);
|
|
|
|
}
|
|
|
|
PostQuitMessage(0);
|
2001-02-23 02:12:26 +01:00
|
|
|
break;
|
|
|
|
case WM_PAINT:
|
|
|
|
return Control_WndProc_Paint(panel, lParam1);
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
return Control_WndProc_LButton(panel, lParam2, TRUE);
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
return Control_WndProc_LButton(panel, lParam2, FALSE);
|
|
|
|
/* EPP case WM_COMMAND: */
|
|
|
|
/* EPP return Control_WndProc_Command(mwi, lParam1, lParam2); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProcA(hWnd, wMsg, lParam1, lParam2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Control_DoInterface(CPanel* panel, HWND hWnd, HINSTANCE hInst)
|
|
|
|
{
|
|
|
|
WNDCLASSA wc;
|
|
|
|
MSG msg;
|
2003-12-11 05:24:16 +01:00
|
|
|
const CHAR* appName = "Wine Control Panel";
|
2001-02-23 02:12:26 +01:00
|
|
|
wc.style = CS_HREDRAW|CS_VREDRAW;
|
|
|
|
wc.lpfnWndProc = Control_WndProc;
|
|
|
|
wc.cbClsExtra = 0;
|
|
|
|
wc.cbWndExtra = sizeof(CPlApplet*);
|
|
|
|
wc.hInstance = hInst;
|
|
|
|
wc.hIcon = 0;
|
|
|
|
wc.hCursor = 0;
|
|
|
|
wc.hbrBackground = GetStockObject(WHITE_BRUSH);
|
|
|
|
wc.lpszMenuName = NULL;
|
|
|
|
wc.lpszClassName = "Shell_Control_WndClass";
|
|
|
|
|
|
|
|
if (!RegisterClassA(&wc)) return;
|
|
|
|
|
2003-12-11 05:24:16 +01:00
|
|
|
CreateWindowExA(0, wc.lpszClassName, appName,
|
2002-06-01 01:06:46 +02:00
|
|
|
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
2002-12-02 19:10:57 +01:00
|
|
|
hWnd, NULL, hInst, panel);
|
2001-02-23 02:12:26 +01:00
|
|
|
if (!panel->hWnd) return;
|
2003-12-11 05:24:16 +01:00
|
|
|
|
|
|
|
if (!panel->first) {
|
|
|
|
/* FIXME appName & message should be localized */
|
|
|
|
MessageBoxA(panel->hWnd, "Cannot load any applets", appName, MB_OK);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
while (GetMessageA(&msg, panel->hWnd, 0, 0)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageA(&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-02 19:08:42 +02:00
|
|
|
static void Control_RegisterRegistryApplets(HWND hWnd, CPanel *panel, HKEY hkey_root, LPCWSTR szRepPath)
|
|
|
|
{
|
|
|
|
WCHAR name[MAX_PATH];
|
|
|
|
WCHAR value[MAX_PATH];
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
if (RegOpenKeyW(hkey_root, szRepPath, &hkey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
for(;; ++idx)
|
|
|
|
{
|
|
|
|
DWORD nameLen = MAX_PATH;
|
|
|
|
DWORD valueLen = MAX_PATH;
|
|
|
|
|
|
|
|
if (RegEnumValueW(hkey, idx, name, &nameLen, NULL, NULL, (LPBYTE)&value, &valueLen) != ERROR_SUCCESS)
|
|
|
|
break;
|
|
|
|
|
|
|
|
Control_LoadApplet(hWnd, value, panel);
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
static void Control_DoWindow(CPanel* panel, HWND hWnd, HINSTANCE hInst)
|
|
|
|
{
|
|
|
|
HANDLE h;
|
2002-12-13 03:17:54 +01:00
|
|
|
WIN32_FIND_DATAW fd;
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
static const WCHAR wszAllCpl[] = {'*','.','c','p','l',0};
|
2008-07-02 19:08:42 +02:00
|
|
|
static const WCHAR wszRegPath[] = {'S','O','F','T','W','A','R','E','\\','M','i','c','r','o','s','o','f','t',
|
|
|
|
'\\','W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',
|
|
|
|
'\\','C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','C','p','l','s',0};
|
2002-12-13 03:17:54 +01:00
|
|
|
WCHAR *p;
|
|
|
|
|
2008-07-02 19:08:42 +02:00
|
|
|
/* first add .cpl files in the system directory */
|
2002-12-13 03:17:54 +01:00
|
|
|
GetSystemDirectoryW( buffer, MAX_PATH );
|
|
|
|
p = buffer + strlenW(buffer);
|
|
|
|
*p++ = '\\';
|
|
|
|
lstrcpyW(p, wszAllCpl);
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2003-12-11 05:24:16 +01:00
|
|
|
if ((h = FindFirstFileW(buffer, &fd)) != INVALID_HANDLE_VALUE) {
|
2001-02-23 02:12:26 +01:00
|
|
|
do {
|
2002-12-13 03:17:54 +01:00
|
|
|
lstrcpyW(p, fd.cFileName);
|
2001-02-23 02:12:26 +01:00
|
|
|
Control_LoadApplet(hWnd, buffer, panel);
|
2002-12-13 03:17:54 +01:00
|
|
|
} while (FindNextFileW(h, &fd));
|
2001-02-23 02:12:26 +01:00
|
|
|
FindClose(h);
|
|
|
|
}
|
|
|
|
|
2008-07-02 19:08:42 +02:00
|
|
|
/* now check for cpls in the registry */
|
|
|
|
Control_RegisterRegistryApplets(hWnd, panel, HKEY_LOCAL_MACHINE, wszRegPath);
|
|
|
|
Control_RegisterRegistryApplets(hWnd, panel, HKEY_CURRENT_USER, wszRegPath);
|
|
|
|
|
2003-12-11 05:24:16 +01:00
|
|
|
Control_DoInterface(panel, hWnd, hInst);
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
|
|
|
|
2002-12-13 03:17:54 +01:00
|
|
|
static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
|
2001-02-23 02:12:26 +01:00
|
|
|
/* forms to parse:
|
|
|
|
* foo.cpl,@sp,str
|
|
|
|
* foo.cpl,@sp
|
|
|
|
* foo.cpl,,str
|
|
|
|
* foo.cpl @sp
|
|
|
|
* foo.cpl str
|
2002-11-01 02:46:02 +01:00
|
|
|
* "a path\foo.cpl"
|
2001-02-23 02:12:26 +01:00
|
|
|
*/
|
|
|
|
{
|
2002-12-13 03:17:54 +01:00
|
|
|
LPWSTR buffer;
|
|
|
|
LPWSTR beg = NULL;
|
|
|
|
LPWSTR end;
|
|
|
|
WCHAR ch;
|
|
|
|
LPWSTR ptr;
|
2008-06-23 19:54:11 +02:00
|
|
|
signed sp = -1;
|
|
|
|
LPWSTR extraPmtsBuf = NULL;
|
2002-12-13 03:17:54 +01:00
|
|
|
LPWSTR extraPmts = NULL;
|
2002-10-23 20:44:13 +02:00
|
|
|
int quoted = 0;
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2002-12-13 03:17:54 +01:00
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(wszCmd) + 1) * sizeof(*wszCmd));
|
2001-02-23 02:12:26 +01:00
|
|
|
if (!buffer) return;
|
|
|
|
|
2002-12-13 03:17:54 +01:00
|
|
|
end = lstrcpyW(buffer, wszCmd);
|
2001-02-23 02:12:26 +01:00
|
|
|
|
|
|
|
for (;;) {
|
2008-06-23 19:54:11 +02:00
|
|
|
ch = *end;
|
2002-10-23 20:44:13 +02:00
|
|
|
if (ch == '"') quoted = !quoted;
|
2008-06-23 19:54:11 +02:00
|
|
|
if (!quoted && (ch == ' ' || ch == ',' || ch == '\0')) {
|
|
|
|
*end = '\0';
|
|
|
|
if (beg) {
|
|
|
|
if (*beg == '@') {
|
|
|
|
sp = atoiW(beg + 1);
|
|
|
|
} else if (*beg == '\0') {
|
|
|
|
sp = -1;
|
|
|
|
} else {
|
|
|
|
extraPmtsBuf = beg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ch == '\0') break;
|
|
|
|
beg = end + 1;
|
|
|
|
if (ch == ' ') while (end[1] == ' ') end++;
|
|
|
|
}
|
|
|
|
end++;
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
2002-12-13 03:17:54 +01:00
|
|
|
while ((ptr = StrChrW(buffer, '"')))
|
2003-10-27 23:06:56 +01:00
|
|
|
memmove(ptr, ptr+1, lstrlenW(ptr)*sizeof(WCHAR));
|
2002-10-23 20:44:13 +02:00
|
|
|
|
2008-06-23 19:54:11 +02:00
|
|
|
/* now check for any quotes in extraPmtsBuf and remove */
|
|
|
|
if (extraPmtsBuf != NULL)
|
|
|
|
{
|
|
|
|
beg = end = extraPmtsBuf;
|
|
|
|
quoted = 0;
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
ch = *end;
|
|
|
|
if (ch == '"') quoted = !quoted;
|
|
|
|
if (!quoted && (ch == ' ' || ch == ',' || ch == '\0')) {
|
|
|
|
*end = '\0';
|
|
|
|
if (beg) {
|
|
|
|
if (*beg != '\0') {
|
|
|
|
extraPmts = beg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ch == '\0') break;
|
|
|
|
beg = end + 1;
|
|
|
|
if (ch == ' ') while (end[1] == ' ') end++;
|
|
|
|
}
|
|
|
|
end++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((ptr = StrChrW(extraPmts, '"')))
|
|
|
|
memmove(ptr, ptr+1, lstrlenW(ptr)*sizeof(WCHAR));
|
|
|
|
|
|
|
|
if (extraPmts == NULL)
|
|
|
|
extraPmts = extraPmtsBuf;
|
|
|
|
}
|
|
|
|
|
2002-12-13 03:17:54 +01:00
|
|
|
TRACE("cmd %s, extra %s, sp %d\n", debugstr_w(buffer), debugstr_w(extraPmts), sp);
|
2002-10-23 20:44:13 +02:00
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
Control_LoadApplet(hWnd, buffer, panel);
|
|
|
|
|
|
|
|
if (panel->first) {
|
2008-06-23 19:54:11 +02:00
|
|
|
CPlApplet* applet = panel->first;
|
2001-02-23 02:12:26 +01:00
|
|
|
|
2008-06-23 19:54:11 +02:00
|
|
|
assert(applet && applet->next == NULL);
|
|
|
|
|
|
|
|
/* we've been given a textual parameter (or none at all) */
|
|
|
|
if (sp == -1) {
|
|
|
|
while ((++sp) != applet->count) {
|
|
|
|
if (applet->info[sp].dwSize) {
|
|
|
|
TRACE("sp %d, name %s\n", sp, debugstr_w(applet->info[sp].szName));
|
|
|
|
|
|
|
|
if (StrCmpIW(extraPmts, applet->info[sp].szName) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sp >= applet->count) {
|
|
|
|
WARN("Out of bounds (%u >= %u), setting to 0\n", sp, applet->count);
|
|
|
|
sp = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (applet->info[sp].dwSize) {
|
|
|
|
if (!applet->proc(applet->hWnd, CPL_STARTWPARMSA, sp, (LPARAM)extraPmts))
|
|
|
|
applet->proc(applet->hWnd, CPL_DBLCLK, sp, applet->info[sp].lData);
|
|
|
|
}
|
|
|
|
|
|
|
|
Control_UnloadApplet(applet);
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
2008-06-23 19:54:11 +02:00
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2002-12-13 03:17:54 +01:00
|
|
|
* Control_RunDLLW [SHELL32.@]
|
2001-02-23 02:12:26 +01:00
|
|
|
*
|
|
|
|
*/
|
2002-12-13 03:17:54 +01:00
|
|
|
void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow)
|
2001-02-23 02:12:26 +01:00
|
|
|
{
|
|
|
|
CPanel panel;
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p, %p, %s, 0x%08x)\n",
|
2002-12-13 03:17:54 +01:00
|
|
|
hWnd, hInst, debugstr_w(cmd), nCmdShow);
|
2001-02-23 02:12:26 +01:00
|
|
|
|
|
|
|
memset(&panel, 0, sizeof(panel));
|
|
|
|
|
|
|
|
if (!cmd || !*cmd) {
|
|
|
|
Control_DoWindow(&panel, hWnd, hInst);
|
|
|
|
} else {
|
|
|
|
Control_DoLaunch(&panel, hWnd, cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-13 03:17:54 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Control_RunDLLA [SHELL32.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void WINAPI Control_RunDLLA(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
|
|
|
|
{
|
|
|
|
DWORD len = MultiByteToWideChar(CP_ACP, 0, cmd, -1, NULL, 0 );
|
|
|
|
LPWSTR wszCmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
|
|
|
if (wszCmd && MultiByteToWideChar(CP_ACP, 0, cmd, -1, wszCmd, len ))
|
|
|
|
{
|
|
|
|
Control_RunDLLW(hWnd, hInst, wszCmd, nCmdShow);
|
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(), 0, wszCmd);
|
|
|
|
}
|
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
/*************************************************************************
|
2004-05-27 03:54:30 +02:00
|
|
|
* Control_FillCache_RunDLLW [SHELL32.@]
|
2001-02-23 02:12:26 +01:00
|
|
|
*
|
|
|
|
*/
|
2004-05-27 03:54:30 +02:00
|
|
|
HRESULT WINAPI Control_FillCache_RunDLLW(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
|
2001-02-23 02:12:26 +01:00
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
FIXME("%p %p 0x%08x 0x%08x stub\n", hWnd, hModule, w, x);
|
2001-02-23 02:12:26 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-06-16 21:38:10 +02:00
|
|
|
/*************************************************************************
|
2004-05-27 03:54:30 +02:00
|
|
|
* Control_FillCache_RunDLLA [SHELL32.@]
|
2003-06-16 21:38:10 +02:00
|
|
|
*
|
|
|
|
*/
|
2004-05-27 03:54:30 +02:00
|
|
|
HRESULT WINAPI Control_FillCache_RunDLLA(HWND hWnd, HANDLE hModule, DWORD w, DWORD x)
|
2003-06-16 21:38:10 +02:00
|
|
|
{
|
2004-05-27 03:54:30 +02:00
|
|
|
return Control_FillCache_RunDLLW(hWnd, hModule, w, x);
|
2003-06-16 21:38:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-23 02:12:26 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* RunDLL_CallEntry16 [SHELL32.122]
|
2001-12-26 21:34:12 +01:00
|
|
|
* the name is probably wrong
|
2001-02-23 02:12:26 +01:00
|
|
|
*/
|
2003-12-03 05:44:52 +01:00
|
|
|
void WINAPI RunDLL_CallEntry16( DWORD proc, HWND hwnd, HINSTANCE inst,
|
|
|
|
LPCSTR cmdline, INT cmdshow )
|
2001-02-23 02:12:26 +01:00
|
|
|
{
|
2003-12-03 05:44:52 +01:00
|
|
|
WORD args[5];
|
|
|
|
SEGPTR cmdline_seg;
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE( "proc %x hwnd %p inst %p cmdline %s cmdshow %d\n",
|
2003-12-03 05:44:52 +01:00
|
|
|
proc, hwnd, inst, debugstr_a(cmdline), cmdshow );
|
|
|
|
|
|
|
|
cmdline_seg = MapLS( cmdline );
|
|
|
|
args[4] = HWND_16(hwnd);
|
|
|
|
args[3] = MapHModuleLS(inst);
|
|
|
|
args[2] = SELECTOROF(cmdline_seg);
|
|
|
|
args[1] = OFFSETOF(cmdline_seg);
|
|
|
|
args[0] = cmdshow;
|
|
|
|
WOWCallback16Ex( proc, WCB16_PASCAL, sizeof(args), args, NULL );
|
|
|
|
UnMapLS( cmdline_seg );
|
2001-02-23 02:12:26 +01:00
|
|
|
}
|
2001-12-26 21:34:12 +01:00
|
|
|
|
2002-01-07 22:16:46 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* CallCPLEntry16 [SHELL32.166]
|
|
|
|
*
|
2001-12-26 21:34:12 +01:00
|
|
|
* called by desk.cpl on "Advanced" with:
|
|
|
|
* hMod("DeskCp16.Dll"), pFunc("CplApplet"), 0, 1, 0xc, 0
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WINAPI CallCPLEntry16(HMODULE hMod, FARPROC pFunc, DWORD dw3, DWORD dw4, DWORD dw5, DWORD dw6)
|
|
|
|
{
|
2006-10-07 20:18:14 +02:00
|
|
|
FIXME("(%p, %p, %08x, %08x, %08x, %08x): stub.\n", hMod, pFunc, dw3, dw4, dw5, dw6);
|
2001-12-26 21:34:12 +01:00
|
|
|
return 0x0deadbee;
|
|
|
|
}
|