shell32 patch 23f
Martin Fuchs
martin-fuchs at gmx.net
Sat Apr 3 03:42:35 CST 2004
Changelog:
check for folders in ShellExecute()
Index: shlexec.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlexec.c,v
retrieving revision 1.38
diff -u -p -d -r1.38 shlexec.c
--- shlexec.c 1 Apr 2004 21:00:23 -0000 1.38
+++ shlexec.c 3 Apr 2004 09:40:50 -0000
@@ -56,6 +56,7 @@ static const WCHAR wszOpen[] = {'o','p',
static const WCHAR wszExe[] = {'.','e','x','e',0};
static const WCHAR wszILPtr[] = {':','%','p',0};
static const WCHAR wszShell[] = {'\\','s','h','e','l','l','\\',0};
+static const WCHAR wszFolder[] = {'F','o','l','d','e','r',0};
/***********************************************************************
@@ -419,6 +420,7 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath
UINT retval = 31; /* default - 'No association was found' */
WCHAR *tok; /* token pointer */
WCHAR xlpFile[256] = {0}; /* result of SearchPath */
+ DWORD attribs; /* file attributes */
TRACE("%s\n", (lpFile != NULL) ? debugstr_w(lpFile) : "-");
@@ -446,72 +448,81 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath
/* Hey, isn't this value ignored? Why make this call? Shouldn't we return here? --dank*/
}
- /* First thing we need is the file's extension */
- extension = strrchrW(xlpFile, '.'); /* Assume last "." is the one; */
- /* File->Run in progman uses */
- /* .\FILE.EXE :( */
- TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile), debugstr_w(extension));
-
- if ((extension == NULL) || (extension == &xlpFile[strlenW(xlpFile)]))
+ attribs = GetFileAttributesW(lpFile);
+ if (attribs!=INVALID_FILE_ATTRIBUTES && (attribs&FILE_ATTRIBUTE_DIRECTORY))
{
- WARN("Returning 31 - No association\n");
- return 31; /* no association */
+ strcpyW(filetype, wszFolder);
+ filetypelen = 6; /* strlen("Folder") */
}
+ else
+ {
+ /* First thing we need is the file's extension */
+ extension = strrchrW(xlpFile, '.'); /* Assume last "." is the one; */
+ /* File->Run in progman uses */
+ /* .\FILE.EXE :( */
+ TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile), debugstr_w(extension));
- /* Make local copy & lowercase it for reg & 'programs=' lookup */
- lstrcpynW(wtmpext, extension, 5);
- CharLowerW(wtmpext);
- TRACE("%s file\n", debugstr_w(wtmpext));
+ if ((extension == NULL) || (extension == &xlpFile[strlenW(xlpFile)]))
+ {
+ WARN("Returning 31 - No association\n");
+ return 31; /* no association */
+ }
- /* Three places to check: */
- /* 1. win.ini, [windows], programs (NB no leading '.') */
- /* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
- /* 3. win.ini, [extensions], extension (NB no leading '.' */
- /* All I know of the order is that registry is checked before */
- /* extensions; however, it'd make sense to check the programs */
- /* section first, so that's what happens here. */
+ /* Make local copy & lowercase it for reg & 'programs=' lookup */
+ lstrcpynW(wtmpext, extension, 5);
+ CharLowerW(wtmpext);
+ TRACE("%s file\n", debugstr_w(wtmpext));
- /* See if it's a program - if GetProfileString fails, we skip this
- * section. Actually, if GetProfileString fails, we've probably
- * got a lot more to worry about than running a program... */
- if (GetProfileStringW(wWindows, wPrograms, wExtensions, wBuffer, sizeof(wBuffer)/sizeof(WCHAR)) > 0)
- {
- CharLowerW(wBuffer);
- tok = wBuffer;
- while (*tok)
- {
- WCHAR *p = tok;
- while (*p && *p != ' ' && *p != '\t') p++;
- if (*p)
- {
- *p++ = 0;
- while (*p == ' ' || *p == '\t') p++;
- }
+ /* Three places to check: */
+ /* 1. win.ini, [windows], programs (NB no leading '.') */
+ /* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
+ /* 3. win.ini, [extensions], extension (NB no leading '.' */
+ /* All I know of the order is that registry is checked before */
+ /* extensions; however, it'd make sense to check the programs */
+ /* section first, so that's what happens here. */
- if (strcmpW(tok, &wtmpext[1]) == 0) /* have to skip the leading "." */
- {
- strcpyW(lpResult, xlpFile);
- /* Need to perhaps check that the file has a path
- * attached */
- TRACE("found %s\n", debugstr_w(lpResult));
- return 33;
+ /* See if it's a program - if GetProfileString fails, we skip this
+ * section. Actually, if GetProfileString fails, we've probably
+ * got a lot more to worry about than running a program... */
+ if (GetProfileStringW(wWindows, wPrograms, wExtensions, wBuffer, sizeof(wBuffer)/sizeof(WCHAR)) > 0)
+ {
+ CharLowerW(wBuffer);
+ tok = wBuffer;
+ while (*tok)
+ {
+ WCHAR *p = tok;
+ while (*p && *p != ' ' && *p != '\t') p++;
+ if (*p)
+ {
+ *p++ = 0;
+ while (*p == ' ' || *p == '\t') p++;
+ }
- /* Greater than 32 to indicate success FIXME According to the
- * docs, I should be returning a handle for the
- * executable. Does this mean I'm supposed to open the
- * executable file or something? More RTFM, I guess... */
- }
- tok = p;
- }
- }
+ if (strcmpW(tok, &wtmpext[1]) == 0) /* have to skip the leading "." */
+ {
+ strcpyW(lpResult, xlpFile);
+ /* Need to perhaps check that the file has a path
+ * attached */
+ TRACE("found %s\n", debugstr_w(lpResult));
+ return 33;
- /* Check registry */
- if (RegQueryValueW(HKEY_CLASSES_ROOT, wtmpext, filetype,
- &filetypelen) == ERROR_SUCCESS)
- {
- filetypelen /= sizeof(WCHAR);
- filetype[filetypelen] = '\0';
- TRACE("File type: %s\n", debugstr_w(filetype));
+ /* Greater than 32 to indicate success FIXME According to the
+ * docs, I should be returning a handle for the
+ * executable. Does this mean I'm supposed to open the
+ * executable file or something? More RTFM, I guess... */
+ }
+ tok = p;
+ }
+ }
+
+ /* Check registry */
+ if (RegQueryValueW(HKEY_CLASSES_ROOT, wtmpext, filetype,
+ &filetypelen) == ERROR_SUCCESS)
+ {
+ filetypelen /= sizeof(WCHAR);
+ filetype[filetypelen] = '\0';
+ TRACE("File type: %s\n", debugstr_w(filetype));
+ }
}
if (*filetype)
More information about the wine-patches
mailing list