mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 22:33:00 +00:00
[SHELL32] Do not return -1 if a file is not valid or not found - ExtractIconEx() (#2113)
ExtractIconEx() returns the number of successfully extracted icons from a file. The routine may return 0 in case no icons could be extracted but it could also return 0 if the file is not a valid PE image file or the file couldn't be found. PrivateExtractIcons and the internal USER32 routine, ICO_ExtractIconExW(), return -1 in such scenarios. The behaviour is correct however we do not want that ExtractIconEx() returns -1 as well as it doesn't comply with the general documentation. In such cases, simply return 0 as no successful icons have been extracted due to related file failures. CORE-16535
This commit is contained in:
parent
cfdd483c0e
commit
8ec05f5fa1
4 changed files with 56 additions and 4 deletions
37
modules/rostests/apitests/shell32/ExtractIconEx.cpp
Normal file
37
modules/rostests/apitests/shell32/ExtractIconEx.cpp
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* PROJECT: ReactOS API Tests
|
||||
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
|
||||
* PURPOSE: Tests for ExtractIconEx routine
|
||||
* COPYRIGHT: Copyright 2019 Bișoc George (fraizeraust99 at gmail dot com)
|
||||
*/
|
||||
|
||||
#include "shelltest.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PCWSTR pszFilePath;
|
||||
UINT nIcons;
|
||||
} EXTRACTICONTESTS;
|
||||
|
||||
EXTRACTICONTESTS IconTests[] =
|
||||
{
|
||||
/* Executable file with icon */
|
||||
{L"%SystemRoot%\\System32\\cmd.exe", 1},
|
||||
|
||||
/* Executable file without icon */
|
||||
{L"%SystemRoot%\\System32\\autochk.exe", 0},
|
||||
|
||||
/* Non-existing files */
|
||||
{L"%SystemRoot%\\non-existent-file.sdf", 0}
|
||||
};
|
||||
|
||||
START_TEST(ExtractIconEx)
|
||||
{
|
||||
UINT i, nReturnedIcons;
|
||||
|
||||
for (i = 0; i < _countof(IconTests); ++i)
|
||||
{
|
||||
nReturnedIcons = ExtractIconExW(IconTests[i].pszFilePath, 0, NULL, NULL, IconTests[i].nIcons);
|
||||
ok(nReturnedIcons == IconTests[i].nIcons, "ExtractIconExW(%u): Expected %u icons, got %u\n", i, IconTests[i].nIcons, nReturnedIcons);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue