Cleanup the handling of the extension in SHELL_FindExecutable():
- Eliminate the corresponding fixed-size buffer which removes the limitation to 3 character extensions. - Fix handling of the trailing '.' case. - Do a case-insensitive check for the extension in win.ini. Increase the size of the command buffer to 1024.
This commit is contained in:
parent
c6c109a362
commit
e7427e13af
|
@ -516,10 +516,9 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
|
||||||
static const WCHAR wPrograms[] = {'p','r','o','g','r','a','m','s',0};
|
static const WCHAR wPrograms[] = {'p','r','o','g','r','a','m','s',0};
|
||||||
static const WCHAR wExtensions[] = {'e','x','e',' ','p','i','f',' ','b','a','t',' ','c','m','d',' ','c','o','m',0};
|
static const WCHAR wExtensions[] = {'e','x','e',' ','p','i','f',' ','b','a','t',' ','c','m','d',' ','c','o','m',0};
|
||||||
WCHAR *extension = NULL; /* pointer to file extension */
|
WCHAR *extension = NULL; /* pointer to file extension */
|
||||||
WCHAR wtmpext[5]; /* local copy to mung as we please */
|
|
||||||
WCHAR filetype[256]; /* registry name for this filetype */
|
WCHAR filetype[256]; /* registry name for this filetype */
|
||||||
LONG filetypelen = sizeof(filetype); /* length of above */
|
LONG filetypelen = sizeof(filetype); /* length of above */
|
||||||
WCHAR command[256]; /* command from registry */
|
WCHAR command[1024]; /* command from registry */
|
||||||
WCHAR wBuffer[256]; /* Used to GetProfileString */
|
WCHAR wBuffer[256]; /* Used to GetProfileString */
|
||||||
UINT retval = 31; /* default - 'No association was found' */
|
UINT retval = 31; /* default - 'No association was found' */
|
||||||
WCHAR *tok; /* token pointer */
|
WCHAR *tok; /* token pointer */
|
||||||
|
@ -558,17 +557,12 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
|
||||||
/* .\FILE.EXE :( */
|
/* .\FILE.EXE :( */
|
||||||
TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile), debugstr_w(extension));
|
TRACE("xlpFile=%s,extension=%s\n", debugstr_w(xlpFile), debugstr_w(extension));
|
||||||
|
|
||||||
if ((extension == NULL) || (extension == &xlpFile[strlenW(xlpFile)]))
|
if (extension == NULL || extension[1]==0)
|
||||||
{
|
{
|
||||||
WARN("Returning 31 - No association\n");
|
WARN("Returning 31 - No association\n");
|
||||||
return 31; /* no association */
|
return 31; /* no association */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make local copy & lowercase it for reg & 'programs=' lookup */
|
|
||||||
lstrcpynW(wtmpext, extension, 5);
|
|
||||||
CharLowerW(wtmpext);
|
|
||||||
TRACE("%s file\n", debugstr_w(wtmpext));
|
|
||||||
|
|
||||||
/* Three places to check: */
|
/* Three places to check: */
|
||||||
/* 1. win.ini, [windows], programs (NB no leading '.') */
|
/* 1. win.ini, [windows], programs (NB no leading '.') */
|
||||||
/* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
|
/* 2. Registry, HKEY_CLASS_ROOT\<filetype>\shell\open\command */
|
||||||
|
@ -594,7 +588,7 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
|
||||||
while (*p == ' ' || *p == '\t') p++;
|
while (*p == ' ' || *p == '\t') p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmpW(tok, &wtmpext[1]) == 0) /* have to skip the leading "." */
|
if (strcmpiW(tok, &extension[1]) == 0) /* have to skip the leading "." */
|
||||||
{
|
{
|
||||||
strcpyW(lpResult, xlpFile);
|
strcpyW(lpResult, xlpFile);
|
||||||
/* Need to perhaps check that the file has a path
|
/* Need to perhaps check that the file has a path
|
||||||
|
@ -612,7 +606,7 @@ UINT SHELL_FindExecutable(LPCWSTR lpPath, LPCWSTR lpFile, LPCWSTR lpOperation,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check registry */
|
/* Check registry */
|
||||||
if (RegQueryValueW(HKEY_CLASSES_ROOT, wtmpext, filetype,
|
if (RegQueryValueW(HKEY_CLASSES_ROOT, extension, filetype,
|
||||||
&filetypelen) == ERROR_SUCCESS)
|
&filetypelen) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
filetypelen /= sizeof(WCHAR);
|
filetypelen /= sizeof(WCHAR);
|
||||||
|
|
Loading…
Reference in New Issue