Commit d1b77764 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

- Change launch functions to use unicode and implement Control_RunDLLW.

- Enable support for unicode in control panel applications.
parent df357055
...@@ -27,6 +27,10 @@ ...@@ -27,6 +27,10 @@
#include "winuser.h" #include "winuser.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "cpl.h" #include "cpl.h"
#include "wine/unicode.h"
#define NO_SHLWAPI_REG
#include "shlwapi.h"
WINE_DEFAULT_DEBUG_CHANNEL(shlctrl); WINE_DEFAULT_DEBUG_CHANNEL(shlctrl);
...@@ -36,7 +40,7 @@ typedef struct CPlApplet { ...@@ -36,7 +40,7 @@ typedef struct CPlApplet {
unsigned count; /* number of subprograms */ unsigned count; /* number of subprograms */
HMODULE hModule; /* module of loaded applet */ HMODULE hModule; /* module of loaded applet */
APPLET_PROC proc; /* entry point address */ APPLET_PROC proc; /* entry point address */
NEWCPLINFOA info[1]; /* array of count information. NEWCPLINFOW info[1]; /* array of count information.
* dwSize field is 0 if entry is invalid */ * dwSize field is 0 if entry is invalid */
} CPlApplet; } CPlApplet;
...@@ -64,23 +68,24 @@ static CPlApplet* Control_UnloadApplet(CPlApplet* applet) ...@@ -64,23 +68,24 @@ static CPlApplet* Control_UnloadApplet(CPlApplet* applet)
return next; return next;
} }
static CPlApplet* Control_LoadApplet(HWND hWnd, LPCSTR cmd, CPanel* panel) static CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
{ {
CPlApplet* applet; CPlApplet* applet;
unsigned i; unsigned i;
CPLINFO info; CPLINFO info;
NEWCPLINFOW newinfo;
if (!(applet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*applet)))) if (!(applet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*applet))))
return applet; return applet;
applet->hWnd = hWnd; applet->hWnd = hWnd;
if (!(applet->hModule = LoadLibraryA(cmd))) { if (!(applet->hModule = LoadLibraryW(cmd))) {
WARN("Cannot load control panel applet %s\n", cmd); WARN("Cannot load control panel applet %s\n", debugstr_w(cmd));
goto theError; goto theError;
} }
if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule, "CPlApplet"))) { if (!(applet->proc = (APPLET_PROC)GetProcAddress(applet->hModule, "CPlApplet"))) {
WARN("Not a valid control panel applet %s\n", cmd); WARN("Not a valid control panel applet %s\n", debugstr_w(cmd));
goto theError; goto theError;
} }
if (!applet->proc(hWnd, CPL_INIT, 0L, 0L)) { if (!applet->proc(hWnd, CPL_INIT, 0L, 0L)) {
...@@ -93,17 +98,19 @@ static CPlApplet* Control_LoadApplet(HWND hWnd, LPCSTR cmd, CPanel* panel) ...@@ -93,17 +98,19 @@ static CPlApplet* Control_LoadApplet(HWND hWnd, LPCSTR cmd, CPanel* panel)
} }
applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet, applet = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, applet,
sizeof(*applet) + (applet->count - 1) * sizeof(NEWCPLINFOA)); sizeof(*applet) + (applet->count - 1) * sizeof(NEWCPLINFOW));
for (i = 0; i < applet->count; i++) { for (i = 0; i < applet->count; i++) {
applet->info[i].dwSize = sizeof(NEWCPLINFOA); ZeroMemory(&newinfo, sizeof(newinfo));
newinfo.dwSize = sizeof(NEWCPLINFOA);
applet->info[i].dwSize = sizeof(NEWCPLINFOW);
/* proc is supposed to return a null value upon success for /* proc is supposed to return a null value upon success for
* CPL_INQUIRE and CPL_NEWINQUIRE * CPL_INQUIRE and CPL_NEWINQUIRE
* However, real drivers don't seem to behave like this * However, real drivers don't seem to behave like this
* So, use introspection rather than return value * So, use introspection rather than return value
*/ */
applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&applet->info[i]); applet->proc(hWnd, CPL_NEWINQUIRE, i, (LPARAM)&newinfo);
if (applet->info[i].hIcon == 0) { if (newinfo.hIcon == 0) {
applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info); applet->proc(hWnd, CPL_INQUIRE, i, (LPARAM)&info);
if (info.idIcon == 0 || info.idName == 0) { if (info.idIcon == 0 || info.idName == 0) {
WARN("Couldn't get info from sp %u\n", i); WARN("Couldn't get info from sp %u\n", i);
...@@ -113,15 +120,35 @@ static CPlApplet* Control_LoadApplet(HWND hWnd, LPCSTR cmd, CPanel* panel) ...@@ -113,15 +120,35 @@ static CPlApplet* Control_LoadApplet(HWND hWnd, LPCSTR cmd, CPanel* panel)
applet->info[i].dwFlags = 0; applet->info[i].dwFlags = 0;
applet->info[i].dwHelpContext = 0; applet->info[i].dwHelpContext = 0;
applet->info[i].lData = info.lData; applet->info[i].lData = info.lData;
applet->info[i].hIcon = LoadIconA(applet->hModule, applet->info[i].hIcon = LoadIconW(applet->hModule,
MAKEINTRESOURCEA(info.idIcon)); MAKEINTRESOURCEW(info.idIcon));
LoadStringA(applet->hModule, info.idName, LoadStringW(applet->hModule, info.idName,
applet->info[i].szName, sizeof(applet->info[i].szName)); applet->info[i].szName, sizeof(applet->info[i].szName) / sizeof(WCHAR));
LoadStringA(applet->hModule, info.idInfo, LoadStringW(applet->hModule, info.idInfo,
applet->info[i].szInfo, sizeof(applet->info[i].szInfo)); applet->info[i].szInfo, sizeof(applet->info[i].szInfo) / sizeof(WCHAR));
applet->info[i].szHelpFile[0] = '\0'; 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);
MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szName,
sizeof(((LPNEWCPLINFOA)&newinfo)->szName) / sizeof(CHAR),
applet->info[i].szName,
sizeof(applet->info[i].szName) / sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szInfo,
sizeof(((LPNEWCPLINFOA)&newinfo)->szInfo) / sizeof(CHAR),
applet->info[i].szInfo,
sizeof(applet->info[i].szInfo) / sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, ((LPNEWCPLINFOA)&newinfo)->szHelpFile,
sizeof(((LPNEWCPLINFOA)&newinfo)->szHelpFile) / sizeof(CHAR),
applet->info[i].szHelpFile,
sizeof(applet->info[i].szHelpFile) / sizeof(WCHAR));
}
}
} }
applet->next = panel->first; applet->next = panel->first;
...@@ -198,7 +225,7 @@ static LRESULT Control_WndProc_Paint(const CPanel* panel, WPARAM wParam) ...@@ -198,7 +225,7 @@ static LRESULT Control_WndProc_Paint(const CPanel* panel, WPARAM wParam)
txtRect.right = x + XSTEP; txtRect.right = x + XSTEP;
txtRect.top = y + YICON; txtRect.top = y + YICON;
txtRect.bottom = y + YSTEP; txtRect.bottom = y + YSTEP;
DrawTextA(hdc, applet->info[i].szName, -1, &txtRect, DrawTextW(hdc, applet->info[i].szName, -1, &txtRect,
DT_CENTER | DT_VCENTER); DT_CENTER | DT_VCENTER);
x += XSTEP; x += XSTEP;
} }
...@@ -287,22 +314,28 @@ static void Control_DoInterface(CPanel* panel, HWND hWnd, HINSTANCE hInst) ...@@ -287,22 +314,28 @@ static void Control_DoInterface(CPanel* panel, HWND hWnd, HINSTANCE hInst)
static void Control_DoWindow(CPanel* panel, HWND hWnd, HINSTANCE hInst) static void Control_DoWindow(CPanel* panel, HWND hWnd, HINSTANCE hInst)
{ {
HANDLE h; HANDLE h;
WIN32_FIND_DATAA fd; WIN32_FIND_DATAW fd;
char buffer[MAX_PATH]; WCHAR buffer[MAX_PATH];
static const WCHAR wszAllCpl[] = {'*','.','c','p','l',0};
WCHAR *p;
GetSystemDirectoryW( buffer, MAX_PATH );
p = buffer + strlenW(buffer);
*p++ = '\\';
lstrcpyW(p, wszAllCpl);
/* FIXME: should grab path somewhere from configuration */ if ((h = FindFirstFileW(buffer, &fd)) != 0) {
if ((h = FindFirstFileA("c:\\windows\\system\\*.cpl", &fd)) != 0) {
do { do {
sprintf(buffer, "c:\\windows\\system\\%s", fd.cFileName); lstrcpyW(p, fd.cFileName);
Control_LoadApplet(hWnd, buffer, panel); Control_LoadApplet(hWnd, buffer, panel);
} while (FindNextFileA(h, &fd)); } while (FindNextFileW(h, &fd));
FindClose(h); FindClose(h);
} }
if (panel->first) Control_DoInterface(panel, hWnd, hInst); if (panel->first) Control_DoInterface(panel, hWnd, hInst);
} }
static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCSTR cmd) static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCWSTR wszCmd)
/* forms to parse: /* forms to parse:
* foo.cpl,@sp,str * foo.cpl,@sp,str
* foo.cpl,@sp * foo.cpl,@sp
...@@ -312,19 +345,19 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCSTR cmd) ...@@ -312,19 +345,19 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCSTR cmd)
* "a path\foo.cpl" * "a path\foo.cpl"
*/ */
{ {
char* buffer; LPWSTR buffer;
char* beg = NULL; LPWSTR beg = NULL;
char* end; LPWSTR end;
char ch; WCHAR ch;
char* ptr; LPWSTR ptr;
unsigned sp = 0; unsigned sp = 0;
char* extraPmts = NULL; LPWSTR extraPmts = NULL;
int quoted = 0; int quoted = 0;
buffer = HeapAlloc(GetProcessHeap(), 0, strlen(cmd) + 1); buffer = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(wszCmd) + 1) * sizeof(*wszCmd));
if (!buffer) return; if (!buffer) return;
end = strcpy(buffer, cmd); end = lstrcpyW(buffer, wszCmd);
for (;;) { for (;;) {
ch = *end; ch = *end;
...@@ -333,7 +366,7 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCSTR cmd) ...@@ -333,7 +366,7 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCSTR cmd)
*end = '\0'; *end = '\0';
if (beg) { if (beg) {
if (*beg == '@') { if (*beg == '@') {
sp = atoi(beg + 1); sp = atoiW(beg + 1);
} else if (*beg == '\0') { } else if (*beg == '\0') {
sp = 0; sp = 0;
} else { } else {
...@@ -346,10 +379,10 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCSTR cmd) ...@@ -346,10 +379,10 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCSTR cmd)
} }
end++; end++;
} }
while ((ptr = strchr(buffer, (int) '"'))) while ((ptr = StrChrW(buffer, '"')))
memmove(ptr, ptr+1, strlen(ptr)); memmove(ptr, ptr+1, lstrlenW(ptr));
TRACE("cmd %s, extra %s, sp %d\n", buffer, debugstr_a(extraPmts), sp); TRACE("cmd %s, extra %s, sp %d\n", debugstr_w(buffer), debugstr_w(extraPmts), sp);
Control_LoadApplet(hWnd, buffer, panel); Control_LoadApplet(hWnd, buffer, panel);
...@@ -371,15 +404,15 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCSTR cmd) ...@@ -371,15 +404,15 @@ static void Control_DoLaunch(CPanel* panel, HWND hWnd, LPCSTR cmd)
} }
/************************************************************************* /*************************************************************************
* Control_RunDLL [SHELL32.@] * Control_RunDLLW [SHELL32.@]
* *
*/ */
void WINAPI Control_RunDLL(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow) void WINAPI Control_RunDLLW(HWND hWnd, HINSTANCE hInst, LPCWSTR cmd, DWORD nCmdShow)
{ {
CPanel panel; CPanel panel;
TRACE("(%p, 0x%08lx, %s, 0x%08lx)\n", TRACE("(%p, %p, %s, 0x%08lx)\n",
hWnd, (DWORD)hInst, debugstr_a(cmd), nCmdShow); hWnd, hInst, debugstr_w(cmd), nCmdShow);
memset(&panel, 0, sizeof(panel)); memset(&panel, 0, sizeof(panel));
...@@ -391,6 +424,21 @@ void WINAPI Control_RunDLL(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdSho ...@@ -391,6 +424,21 @@ void WINAPI Control_RunDLL(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdSho
} }
/************************************************************************* /*************************************************************************
* 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);
}
/*************************************************************************
* Control_FillCache_RunDLL [SHELL32.@] * Control_FillCache_RunDLL [SHELL32.@]
* *
*/ */
......
...@@ -312,9 +312,9 @@ ...@@ -312,9 +312,9 @@
@ stdcall Control_FillCache_RunDLL(long long long long)Control_FillCache_RunDLL @ stdcall Control_FillCache_RunDLL(long long long long)Control_FillCache_RunDLL
@ stub Control_FillCache_RunDLLA @ stub Control_FillCache_RunDLLA
@ stub Control_FillCache_RunDLLW @ stub Control_FillCache_RunDLLW
@ stdcall Control_RunDLL(long long long long)Control_RunDLL @ stdcall Control_RunDLL(ptr ptr str long) Control_RunDLLA
@ stub Control_RunDLLA @ stdcall Control_RunDLLA(ptr ptr str long) Control_RunDLLA
@ stub Control_RunDLLW @ stdcall Control_RunDLLW(ptr ptr wstr long) Control_RunDLLW
@ stdcall DllInstall(long wstr)SHELL32_DllInstall @ stdcall DllInstall(long wstr)SHELL32_DllInstall
@ stdcall DoEnvironmentSubstA(str str)DoEnvironmentSubstA @ stdcall DoEnvironmentSubstA(str str)DoEnvironmentSubstA
@ stdcall DoEnvironmentSubstW(wstr wstr)DoEnvironmentSubstW @ stdcall DoEnvironmentSubstW(wstr wstr)DoEnvironmentSubstW
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment