Changeset 9799 for trunk/src/shell32/control.c
- Timestamp:
- Feb 13, 2003, 4:29:57 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/shell32/control.c
r6709 r9799 1 /* Control Panel management */ 2 /* Eric Pouech 2001 */ 1 /* Control Panel management 2 * 3 * Copyright 2001 Eric Pouech 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 */ 3 19 4 20 #include <assert.h> … … 10 26 #include "wingdi.h" 11 27 #include "winuser.h" 12 #include " debugtools.h"28 #include "wine/debug.h" 13 29 #include "cpl.h" 14 15 DEFAULT_DEBUG_CHANNEL(shlctrl); 30 #include "wine/unicode.h" 31 32 #define NO_SHLWAPI_REG 33 #include "shlwapi.h" 34 35 WINE_DEFAULT_DEBUG_CHANNEL(shlctrl); 16 36 17 37 typedef struct CPlApplet { … … 21 41 HMODULE hModule; /* module of loaded applet */ 22 42 APPLET_PROC proc; /* entry point address */ 23 NEWCPLINFO A info[1]; /* array of count information.43 NEWCPLINFOW info[1]; /* array of count information. 24 44 * dwSize field is 0 if entry is invalid */ 25 45 } CPlApplet; … … 49 69 } 50 70 51 static CPlApplet* Control_LoadApplet(HWND hWnd, LPC STR cmd, CPanel* panel)71 static CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel) 52 72 { 53 73 CPlApplet* applet; 54 74 unsigned i; 55 75 CPLINFO info; 76 NEWCPLINFOW newinfo; 56 77 57 78 if (!(applet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*applet)))) … … 60 81 applet->hWnd = hWnd; 61 82 62 if (!(applet->hModule = LoadLibrary A(cmd))) {63 WARN("Cannot load control panel applet %s\n", cmd);83 if (!(applet->hModule = LoadLibraryW(cmd))) { 84 WARN("Cannot load control panel applet %s\n", debugstr_w(cmd)); 64 85 goto theError; 65 86 } 66 87 if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule, "CPlApplet"))) { 67 WARN("Not a valid control panel applet %s\n", cmd);88 WARN("Not a valid control panel applet %s\n", debugstr_w(cmd)); 68 89 goto theError; 69 90 } … … 77 98 } 78 99 79 applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet, 80 sizeof(*applet) + (applet->count - 1) * sizeof(NEWCPLINFO A));81 100 applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet, 101 sizeof(*applet) + (applet->count - 1) * sizeof(NEWCPLINFOW)); 102 82 103 for (i = 0; i < applet->count; i++) { 83 applet->info[i].dwSize = sizeof(NEWCPLINFOA); 104 ZeroMemory(&newinfo, sizeof(newinfo)); 105 newinfo.dwSize = sizeof(NEWCPLINFOA); 106 applet->info[i].dwSize = sizeof(NEWCPLINFOW); 84 107 /* proc is supposed to return a null value upon success for 85 108 * CPL_INQUIRE and CPL_NEWINQUIRE … … 87 110 * So, use introspection rather than return value 88 111 */ 89 applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)& applet->info[i]);90 if ( applet->info[i].hIcon == 0) {112 applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo); 113 if (newinfo.hIcon == 0) { 91 114 applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info); 92 115 if (info.idIcon == 0 || info.idName == 0) { … … 98 121 applet->info[i].dwHelpContext = 0; 99 122 applet->info[i].lData = info.lData; 100 applet->info[i].hIcon = LoadIcon A(applet->hModule,101 MAKEINTRESOURCE A(info.idIcon));102 LoadString A(applet->hModule, info.idName,103 applet->info[i].szName, sizeof(applet->info[i].szName) );104 LoadString A(applet->hModule, info.idInfo,105 applet->info[i].szInfo, sizeof(applet->info[i].szInfo) );123 applet->info[i].hIcon = LoadIconW(applet->hModule, 124 MAKEINTRESOURCEW(info.idIcon)); 125 LoadStringW(applet->hModule, info.idName, 126 applet->info[i].szName, sizeof(applet->info[i].szName) / sizeof(WCHAR)); 127 LoadStringW(applet->hModule, info.idInfo, 128 applet->info[i].szInfo, sizeof(applet->info[i].szInfo) / sizeof(WCHAR)); 106 129 applet->info[i].szHelpFile[0] = '\0'; 107 130 } 131 } 132 else 133 { 134 CopyMemory(&applet->info[i], &newinfo, newinfo.dwSize); 135 if (newinfo.dwSize != sizeof(NEWCPLINFOW)) 136 { 137 applet->info[i].dwSize = sizeof(NEWCPLINFOW); 138 MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szName, 139 sizeof(((LPNEWCPLINFOA)&newinfo)->szName) / sizeof(CHAR), 140 applet->info[i].szName, 141 sizeof(applet->info[i].szName) / sizeof(WCHAR)); 142 MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szInfo, 143 sizeof(((LPNEWCPLINFOA)&newinfo)->szInfo) / sizeof(CHAR), 144 applet->info[i].szInfo, 145 sizeof(applet->info[i].szInfo) / sizeof(WCHAR)); 146 MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szHelpFile, 147 sizeof(((LPNEWCPLINFOA)&newinfo)->szHelpFile) / sizeof(CHAR), 148 applet->info[i].szHelpFile, 149 sizeof(applet->info[i].szHelpFile) / sizeof(WCHAR)); 150 } 108 151 } 109 152 } … … 139 182 CPlApplet* applet; 140 183 RECT rc; 141 184 142 185 GetClientRect(panel->hWnd, &rc); 143 186 for (applet = panel->first; applet; applet = applet = applet->next) { … … 183 226 txtRect.top = y + YICON; 184 227 txtRect.bottom = y + YSTEP; 185 DrawText A(hdc, applet->info[i].szName, -1, &txtRect,228 DrawTextW(hdc, applet->info[i].szName, -1, &txtRect, 186 229 DT_CENTER | DT_VCENTER); 187 230 x += XSTEP; … … 197 240 unsigned i; 198 241 CPlApplet* applet; 199 242 200 243 if (Control_Localize(panel, LOWORD(lParam), HIWORD(lParam), &applet, &i)) { 201 244 if (up) { … … 211 254 } 212 255 213 static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg, 256 static LRESULT WINAPI Control_WndProc(HWND hWnd, UINT wMsg, 214 257 WPARAM lParam1, LPARAM lParam2) 215 258 { … … 256 299 if (!RegisterClassA(&wc)) return; 257 300 258 CreateWindowExA(0, wc.lpszClassName, "Wine Control Panel", 259 WS_OVERLAPPEDWINDOW | WS_VISIBLE, 260 CW_USEDEFAULT, CW_USEDEFAULT, 261 CW_USEDEFAULT, CW_USEDEFAULT, 262 hWnd, (HMENU)0, hInst, panel);301 CreateWindowExA(0, wc.lpszClassName, "Wine Control Panel", 302 WS_OVERLAPPEDWINDOW | WS_VISIBLE, 303 CW_USEDEFAULT, CW_USEDEFAULT, 304 CW_USEDEFAULT, CW_USEDEFAULT, 305 hWnd, NULL, hInst, panel); 263 306 if (!panel->hWnd) return; 264 307 while (GetMessageA(&msg, panel->hWnd, 0, 0)) { … … 272 315 { 273 316 HANDLE h; 274 WIN32_FIND_DATAA fd; 275 char buffer[MAX_PATH]; 276 277 /* FIXME: should grab path somewhere from configuration */ 278 if ((h = FindFirstFileA("c:\\windows\\system\\*.cpl", &fd)) != 0) { 317 WIN32_FIND_DATAW fd; 318 WCHAR buffer[MAX_PATH]; 319 static const WCHAR wszAllCpl[] = {'*','.','c','p','l',0}; 320 WCHAR *p; 321 322 GetSystemDirectoryW( buffer, MAX_PATH ); 323 p = buffer + strlenW(buffer); 324 *p++ = '\\'; 325 lstrcpyW(p, wszAllCpl); 326 327 if ((h = FindFirstFileW(buffer, &fd)) != 0) { 279 328 do { 280 sprintf(buffer, "c:\\windows\\system\\%s", fd.cFileName);329 lstrcpyW(p, fd.cFileName); 281 330 Control_LoadApplet(hWnd, buffer, panel); 282 } while (FindNextFile A(h, &fd));331 } while (FindNextFileW(h, &fd)); 283 332 FindClose(h); 284 333 } … … 287 336 } 288 337 289 static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPC STR cmd)338 static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd) 290 339 /* forms to parse: 291 340 * foo.cpl,@sp,str … … 294 343 * foo.cpl @sp 295 344 * foo.cpl str 345 * "a path\foo.cpl" 296 346 */ 297 347 { 298 char* buffer; 299 char* beg = NULL; 300 char* end; 301 char ch; 348 LPWSTR buffer; 349 LPWSTR beg = NULL; 350 LPWSTR end; 351 WCHAR ch; 352 LPWSTR ptr; 302 353 unsigned sp = 0; 303 char* extraPmts = NULL; 304 305 buffer = HeapAlloc(GetProcessHeap(), 0, strlen(cmd) + 1); 354 LPWSTR extraPmts = NULL; 355 int quoted = 0; 356 357 buffer = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(wszCmd) + 1) * sizeof(*wszCmd)); 306 358 if (!buffer) return; 307 359 308 end = strcpy(buffer, cmd);360 end = lstrcpyW(buffer, wszCmd); 309 361 310 362 for (;;) { 311 363 ch = *end; 312 if (ch == ' ' || ch == ',' || ch == '\0') { 364 if (ch == '"') quoted = !quoted; 365 if (!quoted && (ch == ' ' || ch == ',' || ch == '\0')) { 313 366 *end = '\0'; 314 367 if (beg) { 315 368 if (*beg == '@') { 316 sp = atoi (beg + 1);369 sp = atoiW(beg + 1); 317 370 } else if (*beg == '\0') { 318 371 sp = 0; … … 327 380 end++; 328 381 } 382 while ((ptr = StrChrW(buffer, '"'))) 383 memmove(ptr, ptr+1, lstrlenW(ptr)); 384 385 TRACE("cmd %s, extra %s, sp %d\n", debugstr_w(buffer), debugstr_w(extraPmts), sp); 386 329 387 Control_LoadApplet(hWnd, buffer, panel); 330 388 … … 347 405 348 406 /************************************************************************* 349 * Control_RunDLL [SHELL32.12]350 * 351 */ 352 void WINAPI Control_RunDLL (HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)407 * Control_RunDLLW [SHELL32.@] 408 * 409 */ 410 void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow) 353 411 { 354 412 CPanel panel; 355 413 356 TRACE("( 0x%08x, 0x%08lx, %s, 0x%08lx)\n",357 hWnd, (DWORD)hInst, debugstr_a(cmd), nCmdShow);414 TRACE("(%p, %p, %s, 0x%08lx)\n", 415 hWnd, hInst, debugstr_w(cmd), nCmdShow); 358 416 359 417 memset(&panel, 0, sizeof(panel)); … … 367 425 368 426 /************************************************************************* 369 * Control_FillCache_RunDLL [SHELL32.8] 427 * Control_RunDLLA [SHELL32.@] 428 * 429 */ 430 void WINAPI Control_RunDLLA(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow) 431 { 432 DWORD len = MultiByteToWideChar(CP_ACP, 0, cmd, -1, NULL, 0 ); 433 LPWSTR wszCmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); 434 if (wszCmd && MultiByteToWideChar(CP_ACP, 0, cmd, -1, wszCmd, len )) 435 { 436 Control_RunDLLW(hWnd, hInst, wszCmd, nCmdShow); 437 } 438 HeapFree(GetProcessHeap(), 0, wszCmd); 439 } 440 441 /************************************************************************* 442 * Control_FillCache_RunDLL [SHELL32.@] 370 443 * 371 444 */ 372 445 HRESULT WINAPI Control_FillCache_RunDLL(HWND hWnd, HANDLE hModule, DWORD w, DWORD x) 373 446 { 374 FIXME(" 0x%04x 0x%04x 0x%04lx 0x%04lx stub\n",hWnd, hModule, w, x);447 FIXME("%p %p 0x%04lx 0x%04lx stub\n", hWnd, hModule, w, x); 375 448 return 0; 376 449 } … … 378 451 /************************************************************************* 379 452 * RunDLL_CallEntry16 [SHELL32.122] 380 * the name is pro pably wrong453 * the name is probably wrong 381 454 */ 382 455 HRESULT WINAPI RunDLL_CallEntry16(DWORD v, DWORD w, DWORD x, DWORD y, DWORD z) … … 385 458 return 0; 386 459 } 460 461 /************************************************************************* 462 * CallCPLEntry16 [SHELL32.166] 463 * 464 * called by desk.cpl on "Advanced" with: 465 * hMod("DeskCp16.Dll"), pFunc("CplApplet"), 0, 1, 0xc, 0 466 * 467 */ 468 DWORD WINAPI CallCPLEntry16(HMODULE hMod, FARPROC pFunc, DWORD dw3, DWORD dw4, DWORD dw5, DWORD dw6) 469 { 470 FIXME("(%p, %p, %08lx, %08lx, %08lx, %08lx): stub.\n", hMod, pFunc, dw3, dw4, dw5, dw6); 471 return 0x0deadbee; 472 }
Note:
See TracChangeset
for help on using the changeset viewer.