dlls/shell32/control.c - Unicode support for control panel applications and launching
Robert Shearman
R.J.Shearman at warwick.ac.uk
Wed Dec 11 16:02:58 CST 2002
ChangeLog:
- Change launch functions to use unicode and implement Control_RunDLLW
- Enable support for unicode in control panel applications
-------------- next part --------------
Index: wine/dlls/shell32/control.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/control.c,v
retrieving revision 1.11
diff -u -r1.11 control.c
--- wine/dlls/shell32/control.c 2 Dec 2002 18:10:58 -0000 1.11
+++ wine/dlls/shell32/control.c 11 Dec 2002 20:28:25 -0000
@@ -27,6 +27,10 @@
#include "winuser.h"
#include "wine/debug.h"
#include "cpl.h"
+#include "wine/unicode.h"
+
+#define NO_SHLWAPI_REG
+#include "shlwapi.h"
WINE_DEFAULT_DEBUG_CHANNEL(shlctrl);
@@ -36,7 +40,7 @@
unsigned count; /* number of subprograms */
HMODULE hModule; /* module of loaded applet */
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 */
} CPlApplet;
@@ -64,23 +68,24 @@
return next;
}
-static CPlApplet* Control_LoadApplet(HWND hWnd, LPCSTR cmd, CPanel* panel)
+static CPlApplet* Control_LoadApplet(HWND hWnd, LPCWSTR cmd, CPanel* panel)
{
CPlApplet* applet;
unsigned i;
CPLINFO info;
+ NEWCPLINFOW newinfo;
if (!(applet = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*applet))))
return applet;
applet->hWnd = hWnd;
- if (!(applet->hModule = LoadLibraryA(cmd))) {
- WARN("Cannot load control panel applet %s\n", cmd);
+ 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", cmd);
+ WARN("Not a valid control panel applet %s\n", debugstr_w(cmd));
goto theError;
}
if (!applet->proc(hWnd, CPL_INIT, 0L, 0L)) {
@@ -93,17 +98,19 @@
}
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++) {
- 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
* 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)&applet->info[i]);
- if (applet->info[i].hIcon == 0) {
+ 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);
@@ -113,15 +120,35 @@
applet->info[i].dwFlags = 0;
applet->info[i].dwHelpContext = 0;
applet->info[i].lData = info.lData;
- applet->info[i].hIcon = LoadIconA(applet->hModule,
- MAKEINTRESOURCEA(info.idIcon));
- LoadStringA(applet->hModule, info.idName,
- applet->info[i].szName, sizeof(applet->info[i].szName));
- LoadStringA(applet->hModule, info.idInfo,
- applet->info[i].szInfo, sizeof(applet->info[i].szInfo));
+ 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);
+ 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;
@@ -198,7 +225,7 @@
txtRect.right = x + XSTEP;
txtRect.top = y + YICON;
txtRect.bottom = y + YSTEP;
- DrawTextA(hdc, applet->info[i].szName, -1, &txtRect,
+ DrawTextW(hdc, applet->info[i].szName, -1, &txtRect,
DT_CENTER | DT_VCENTER);
x += XSTEP;
}
@@ -287,22 +314,33 @@
static void Control_DoWindow(CPanel* panel, HWND hWnd, HINSTANCE hInst)
{
HANDLE h;
- WIN32_FIND_DATAA fd;
- char buffer[MAX_PATH];
+ WIN32_FIND_DATAW fd;
+ WCHAR buffer[MAX_PATH];
+ const WCHAR wszAllCpl[] = {'\\','*','.','c','p','l',0};
+ int end;
+
+ /* FIXME: get from registry */
+ const WCHAR wszWindowsSystem[] = {'c',':','\\','w','i','n','d','o','w','s','\\','s','y','s','t','e','m',0};
- /* FIXME: should grab path somewhere from configuration */
- if ((h = FindFirstFileA("c:\\windows\\system\\*.cpl", &fd)) != 0) {
+ lstrcpyW(buffer, wszWindowsSystem);
+ lstrcatW(buffer, wszAllCpl);
+
+ if ((h = FindFirstFileW(buffer, &fd)) != 0) {
do {
- sprintf(buffer, "c:\\windows\\system\\%s", fd.cFileName);
+ lstrcpyW(buffer, wszWindowsSystem);
+ end = lstrlenW(buffer);
+ buffer[end] = '\\';
+ buffer[end + 1] = 0;
+ lstrcatW(buffer, fd.cFileName);
Control_LoadApplet(hWnd, buffer, panel);
- } while (FindNextFileA(h, &fd));
+ } while (FindNextFileW(h, &fd));
FindClose(h);
}
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:
* foo.cpl, at sp,str
* foo.cpl, at sp
@@ -312,19 +350,19 @@
* "a path\foo.cpl"
*/
{
- char* buffer;
- char* beg = NULL;
- char* end;
- char ch;
- char* ptr;
+ LPWSTR buffer;
+ LPWSTR beg = NULL;
+ LPWSTR end;
+ WCHAR ch;
+ LPWSTR ptr;
unsigned sp = 0;
- char* extraPmts = NULL;
+ LPWSTR extraPmts = NULL;
int quoted = 0;
- buffer = HeapAlloc(GetProcessHeap(), 0, strlen(cmd) + 1);
+ buffer = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(wszCmd) + 1) * sizeof(*wszCmd));
if (!buffer) return;
- end = strcpy(buffer, cmd);
+ end = lstrcpyW(buffer, wszCmd);
for (;;) {
ch = *end;
@@ -333,7 +371,7 @@
*end = '\0';
if (beg) {
if (*beg == '@') {
- sp = atoi(beg + 1);
+ sp = atoiW(beg + 1);
} else if (*beg == '\0') {
sp = 0;
} else {
@@ -346,10 +384,10 @@
}
end++;
}
- while ((ptr = strchr(buffer, (int) '"')))
- memmove(ptr, ptr+1, strlen(ptr));
+ while ((ptr = StrChrW(buffer, '"')))
+ 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);
@@ -371,15 +409,15 @@
}
/*************************************************************************
- * 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;
- TRACE("(%p, 0x%08lx, %s, 0x%08lx)\n",
- hWnd, (DWORD)hInst, debugstr_a(cmd), nCmdShow);
+ TRACE("(%p, %p, %s, 0x%08lx)\n",
+ hWnd, hInst, debugstr_w(cmd), nCmdShow);
memset(&panel, 0, sizeof(panel));
@@ -388,6 +426,20 @@
} else {
Control_DoLaunch(&panel, hWnd, cmd);
}
+}
+
+/*************************************************************************
+ * Control_RunDLL(A) [SHELL32.@]
+ *
+ */
+void WINAPI Control_RunDLLA(HWND hWnd, HINSTANCE hInst, LPCSTR cmd, DWORD nCmdShow)
+{
+ LPWSTR wszCmd = HeapAlloc(GetProcessHeap(), 0, (lstrlenA(cmd) + 1) * sizeof(WCHAR));
+ if (wszCmd && MultiByteToWideChar(CP_ACP, 0, cmd, (lstrlenA(cmd) + 1) * sizeof(CHAR), wszCmd, (lstrlenA(cmd) + 1) * sizeof(WCHAR)))
+ {
+ Control_RunDLLW(hWnd, hInst, wszCmd, nCmdShow);
+ }
+ HeapFree(GetProcessHeap(), 0, wszCmd);
}
/*************************************************************************
Index: wine/dlls/shell32/shell32.spec
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shell32.spec,v
retrieving revision 1.60
diff -u -r1.60 shell32.spec
--- wine/dlls/shell32/shell32.spec 7 Dec 2002 23:49:24 -0000 1.60
+++ wine/dlls/shell32/shell32.spec 11 Dec 2002 20:28:28 -0000
@@ -312,9 +312,9 @@
@ stdcall Control_FillCache_RunDLL(long long long long)Control_FillCache_RunDLL
@ stub Control_FillCache_RunDLLA
@ stub Control_FillCache_RunDLLW
-@ stdcall Control_RunDLL(long long long long)Control_RunDLL
-@ stub Control_RunDLLA
-@ stub Control_RunDLLW
+@ stdcall Control_RunDLL(ptr ptr str long) Control_RunDLLA
+@ stdcall Control_RunDLLA(ptr ptr str long) Control_RunDLLA
+@ stdcall Control_RunDLLW(ptr ptr wstr long) Control_RunDLLW
@ stdcall DllInstall(long wstr)SHELL32_DllInstall
@ stdcall DoEnvironmentSubstA(str str)DoEnvironmentSubstA
@ stdcall DoEnvironmentSubstW(wstr wstr)DoEnvironmentSubstW
More information about the wine-patches
mailing list