Module: wine Branch: master Commit: efb92561e69569991dfdbd8c119d57a74d77e219 URL: http://source.winehq.org/git/wine.git/?a=commit;h=efb92561e69569991dfdbd8c11...
Author: Misha Koshelev mk144210@bcm.edu Date: Sun May 27 20:01:10 2007 -0500
shell32: Handle default DDE application names.
---
dlls/shell32/shlexec.c | 47 ++++++++++++++++++++++++++++++++++++++++- dlls/shell32/tests/shlexec.c | 34 +++++++++++++++--------------- 2 files changed, 62 insertions(+), 19 deletions(-)
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c index 0d2b364..edb65ea 100644 --- a/dlls/shell32/shlexec.c +++ b/dlls/shell32/shlexec.c @@ -780,8 +780,51 @@ static unsigned dde_connect(WCHAR* key, const WCHAR* start, WCHAR* ddeexec, applen = sizeof(app); if (RegQueryValueW(HKEY_CLASSES_ROOT, key, app, &applen) != ERROR_SUCCESS) { - FIXME("default app name NIY %s\n", debugstr_w(key)); - return 2; + WCHAR command[1024], fullpath[MAX_PATH]; + static const WCHAR wSo[] = { '.','s','o',0 }; + int sizeSo = sizeof(wSo)/sizeof(WCHAR); + LPWSTR ptr = NULL; + DWORD ret = 0; + + /* Get application command from start string and find filename of application */ + if (*start == '"') + { + strcpyW(command, start+1); + if ((ptr = strchrW(command, '"'))) + *ptr = 0; + ret = SearchPathW(NULL, command, wszExe, sizeof(fullpath)/sizeof(WCHAR), fullpath, &ptr); + } + else + { + LPWSTR p,space; + for (p=(LPWSTR)start; (space=strchrW(p, ' ')); p=space+1) + { + int idx = space-start; + memcpy(command, start, idx*sizeof(WCHAR)); + command[idx] = '\0'; + if ((ret = SearchPathW(NULL, command, wszExe, sizeof(fullpath)/sizeof(WCHAR), fullpath, &ptr))) + break; + } + if (!ret) + ret = SearchPathW(NULL, start, wszExe, sizeof(fullpath)/sizeof(WCHAR), fullpath, &ptr); + } + + if (!ret) + { + ERR("Unable to find application path for command %s\n", debugstr_w(start)); + return ERROR_ACCESS_DENIED; + } + strcpyW(app, ptr); + + /* Remove extensions (including .so) */ + ptr = app + strlenW(app) - (sizeSo-1); + if (strlenW(app) >= sizeSo && + !strcmpW(ptr, wSo)) + *ptr = 0; + + ptr = strrchrW(app, '.'); + assert(ptr); + *ptr = 0; }
strcpyW(endkey, wTopic); diff --git a/dlls/shell32/tests/shlexec.c b/dlls/shell32/tests/shlexec.c index 37f736d..2b19a76 100644 --- a/dlls/shell32/tests/shlexec.c +++ b/dlls/shell32/tests/shlexec.c @@ -1099,7 +1099,7 @@ static dde_tests_t dde_tests[] = {"", "[open("%1")]", "shlexec", NULL, NULL, FALSE, "[open("%s")]", 0x0, 33},
/* Test default DDE application */ - {"", "[open("%1")]", NULL, "dde", NULL, FALSE, "[open("%s")]", 0x1, 33}, + {"", "[open("%1")]", NULL, "dde", NULL, FALSE, "[open("%s")]", 0x0, 33},
{NULL, NULL, NULL, NULL, 0x0, 0} }; @@ -1284,37 +1284,37 @@ typedef struct static dde_default_app_tests_t dde_default_app_tests[] = { /* Test unquoted existing filename with a space */ - {"%s\test file.exe", "test file", 0x1, 33}, - {"%s\test file.exe param", "test file", 0x1, 33}, + {"%s\test file.exe", "test file", 0x0, 33}, + {"%s\test file.exe param", "test file", 0x0, 33},
/* Test quoted existing filename with a space */ - {""%s\test file.exe"", "test file", 0x1, 33}, - {""%s\test file.exe" param", "test file", 0x1, 33}, + {""%s\test file.exe"", "test file", 0x0, 33}, + {""%s\test file.exe" param", "test file", 0x0, 33},
/* Test unquoted filename with a space that doesn't exist, but * test2.exe does */ - {"%s\test2 file.exe", "test2", 0x1, 33}, - {"%s\test2 file.exe param", "test2", 0x1, 33}, + {"%s\test2 file.exe", "test2", 0x0, 33}, + {"%s\test2 file.exe param", "test2", 0x0, 33},
/* Test quoted filename with a space that does not exist */ - {""%s\test2 file.exe"", "", 0x1, 5}, - {""%s\test2 file.exe" param", "", 0x1, 5}, + {""%s\test2 file.exe"", "", 0x0, 5}, + {""%s\test2 file.exe" param", "", 0x0, 5},
/* Test filename supplied without the extension */ - {"%s\test2", "test2", 0x1, 33}, - {"%s\test2 param", "test2", 0x1, 33}, + {"%s\test2", "test2", 0x0, 33}, + {"%s\test2 param", "test2", 0x0, 33},
/* Test an unquoted non-existent filename */ - {"%s\notexist.exe", "", 0x1, 5}, - {"%s\notexist.exe param", "", 0x1, 5}, + {"%s\notexist.exe", "", 0x0, 5}, + {"%s\notexist.exe param", "", 0x0, 5},
/* Test an application that will be found on the path */ - {"cmd", "cmd", 0x1, 33}, - {"cmd param", "cmd", 0x1, 33}, + {"cmd", "cmd", 0x0, 33}, + {"cmd param", "cmd", 0x0, 33},
/* Test an application that will not be found on the path */ - {"xyzwxyzwxyz", "", 0x1, 5}, - {"xyzwxyzwxyz param", "", 0x1, 5}, + {"xyzwxyzwxyz", "", 0x0, 5}, + {"xyzwxyzwxyz param", "", 0x0, 5},
{NULL, NULL, 0, 0} };