Split SHGetFileInfoW into two functions.
This commit is contained in:
parent
ac5b025103
commit
1ae212a105
|
@ -236,60 +236,7 @@ LPWSTR* WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int* numargs)
|
|||
return argv;
|
||||
}
|
||||
|
||||
#define SHGFI_KNOWN_FLAGS \
|
||||
(SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
|
||||
SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
|
||||
SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
|
||||
SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
|
||||
SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
|
||||
|
||||
/*************************************************************************
|
||||
* SHGetFileInfoW [SHELL32.@]
|
||||
*
|
||||
*/
|
||||
DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
|
||||
SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags )
|
||||
{
|
||||
WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH];
|
||||
int iIndex;
|
||||
DWORD ret = TRUE, dwAttributes = 0;
|
||||
IShellFolder * psfParent = NULL;
|
||||
IExtractIconW * pei = NULL;
|
||||
LPITEMIDLIST pidlLast = NULL, pidl = NULL;
|
||||
HRESULT hr = S_OK;
|
||||
BOOL IconNotYetLoaded=TRUE;
|
||||
|
||||
TRACE("%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x\n",
|
||||
(flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes,
|
||||
psfi, psfi->dwAttributes, sizeofpsfi, flags);
|
||||
|
||||
if ( (flags & SHGFI_USEFILEATTRIBUTES) &&
|
||||
(flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
|
||||
return FALSE;
|
||||
|
||||
/* windows initializes this values regardless of the flags */
|
||||
if (psfi != NULL)
|
||||
{
|
||||
psfi->szDisplayName[0] = '\0';
|
||||
psfi->szTypeName[0] = '\0';
|
||||
psfi->iIcon = 0;
|
||||
}
|
||||
|
||||
if (!(flags & SHGFI_PIDL))
|
||||
{
|
||||
/* SHGitFileInfo should work with absolute and relative paths */
|
||||
if (PathIsRelativeW(path))
|
||||
{
|
||||
GetCurrentDirectoryW(MAX_PATH, szLocation);
|
||||
PathCombineW(szFullPath, szLocation, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstrcpynW(szFullPath, path, MAX_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & SHGFI_EXETYPE)
|
||||
static DWORD shgfi_get_exe_type(LPCWSTR szFullPath)
|
||||
{
|
||||
BOOL status = FALSE;
|
||||
HANDLE hfile;
|
||||
|
@ -299,13 +246,10 @@ DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
|
|||
DWORD len;
|
||||
char magic[4];
|
||||
|
||||
if (flags != SHGFI_EXETYPE)
|
||||
return 0;
|
||||
|
||||
status = GetBinaryTypeW (szFullPath, &BinaryType);
|
||||
if (!status)
|
||||
return 0;
|
||||
if ((BinaryType == SCS_DOS_BINARY) || (BinaryType == SCS_PIF_BINARY))
|
||||
if (BinaryType == SCS_DOS_BINARY || BinaryType == SCS_PIF_BINARY)
|
||||
return 0x4d5a;
|
||||
|
||||
hfile = CreateFileW( szFullPath, GENERIC_READ, FILE_SHARE_READ,
|
||||
|
@ -353,6 +297,66 @@ DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define SHGFI_KNOWN_FLAGS \
|
||||
(SHGFI_SMALLICON | SHGFI_OPENICON | SHGFI_SHELLICONSIZE | SHGFI_PIDL | \
|
||||
SHGFI_USEFILEATTRIBUTES | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX | \
|
||||
SHGFI_ICON | SHGFI_DISPLAYNAME | SHGFI_TYPENAME | SHGFI_ATTRIBUTES | \
|
||||
SHGFI_ICONLOCATION | SHGFI_EXETYPE | SHGFI_SYSICONINDEX | \
|
||||
SHGFI_LINKOVERLAY | SHGFI_SELECTED | SHGFI_ATTR_SPECIFIED)
|
||||
|
||||
/*************************************************************************
|
||||
* SHGetFileInfoW [SHELL32.@]
|
||||
*
|
||||
*/
|
||||
DWORD WINAPI SHGetFileInfoW(LPCWSTR path,DWORD dwFileAttributes,
|
||||
SHFILEINFOW *psfi, UINT sizeofpsfi, UINT flags )
|
||||
{
|
||||
WCHAR szLocation[MAX_PATH], szFullPath[MAX_PATH];
|
||||
int iIndex;
|
||||
DWORD ret = TRUE, dwAttributes = 0;
|
||||
IShellFolder * psfParent = NULL;
|
||||
IExtractIconW * pei = NULL;
|
||||
LPITEMIDLIST pidlLast = NULL, pidl = NULL;
|
||||
HRESULT hr = S_OK;
|
||||
BOOL IconNotYetLoaded=TRUE;
|
||||
|
||||
TRACE("%s fattr=0x%lx sfi=%p(attr=0x%08lx) size=0x%x flags=0x%x\n",
|
||||
(flags & SHGFI_PIDL)? "pidl" : debugstr_w(path), dwFileAttributes,
|
||||
psfi, psfi->dwAttributes, sizeofpsfi, flags);
|
||||
|
||||
if ( (flags & SHGFI_USEFILEATTRIBUTES) &&
|
||||
(flags & (SHGFI_ATTRIBUTES|SHGFI_EXETYPE|SHGFI_PIDL)))
|
||||
return FALSE;
|
||||
|
||||
/* windows initializes this values regardless of the flags */
|
||||
if (psfi != NULL)
|
||||
{
|
||||
psfi->szDisplayName[0] = '\0';
|
||||
psfi->szTypeName[0] = '\0';
|
||||
psfi->iIcon = 0;
|
||||
}
|
||||
|
||||
if (!(flags & SHGFI_PIDL))
|
||||
{
|
||||
/* SHGetFileInfo should work with absolute and relative paths */
|
||||
if (PathIsRelativeW(path))
|
||||
{
|
||||
GetCurrentDirectoryW(MAX_PATH, szLocation);
|
||||
PathCombineW(szFullPath, szLocation, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstrcpynW(szFullPath, path, MAX_PATH);
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & SHGFI_EXETYPE)
|
||||
{
|
||||
if (flags != SHGFI_EXETYPE)
|
||||
return 0;
|
||||
return shgfi_get_exe_type(szFullPath);
|
||||
}
|
||||
|
||||
/*
|
||||
* psfi is NULL normally to query EXE type. If it is NULL, none of the
|
||||
* below makes sense anyway. Windows allows this and just returns FALSE
|
||||
|
|
Loading…
Reference in New Issue