For icons/cursors created by CreateIconFromResource(), GetIconInfo() still succeed after they were destroyed, which indicates that these icons/cursors are shared.
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/user32/tests/cursoricon.c | 37 +++++++++++++++------------------- 1 file changed, 16 insertions(+), 21 deletions(-)
diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index a4bdc4f13cf..d73650e08f7 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -1589,12 +1589,16 @@ static void test_CreateIconFromResource(void) SetLastError(0xdeadbeef); handle = CreateIconFromResource((PBYTE) hotspot, CRSR_RES_SIZE, FALSE, 0x00030000); ok(handle != NULL, "Create cursor failed.\n"); + ret = DestroyCursor(handle); + ok(ret, "Destroy cursor failed, error %u.\n", GetLastError());
/* Test the icon information. */ SetLastError(0xdeadbeef); ret = GetIconInfo(handle, &icon_info); + todo_wine ok(ret, "GetIconInfo() failed.\n"); error = GetLastError(); + todo_wine ok(error == 0xdeadbeef, "Last error: %u\n", error);
if (ret) @@ -1612,30 +1616,31 @@ static void test_CreateIconFromResource(void) ICONINFOEXA infoex; infoex.cbSize = sizeof(infoex); ret = pGetIconInfoExA( handle, &infoex ); + todo_wine ok( ret, "GetIconInfoEx failed err %d\n", GetLastError() ); + if (ret) + { ok( infoex.wResID == 0, "GetIconInfoEx wrong resid %x\n", infoex.wResID ); ok( infoex.szModName[0] == 0, "GetIconInfoEx wrong module %s\n", infoex.szModName ); ok( infoex.szResName[0] == 0, "GetIconInfoEx wrong name %s\n", infoex.szResName ); + } }
- /* Clean up. */ - SetLastError(0xdeadbeef); - ret = DestroyCursor(handle); - ok(ret, "DestroyCursor() failed.\n"); - error = GetLastError(); - ok(error == 0xdeadbeef, "Last error: %u\n", error); - /* Test creating an icon. */ SetLastError(0xdeadbeef); handle = CreateIconFromResource((PBYTE) icon_header, ICON_RES_SIZE, TRUE, 0x00030000); ok(handle != NULL, "Create icon failed.\n"); + ret = DestroyIcon(handle); + ok(ret, "Destroy icon failed, error %u.\n", GetLastError());
/* Test the icon information. */ SetLastError(0xdeadbeef); ret = GetIconInfo(handle, &icon_info); + todo_wine ok(ret, "GetIconInfo() failed.\n"); error = GetLastError(); + todo_wine ok(error == 0xdeadbeef, "Last error: %u\n", error);
if (ret) @@ -1648,13 +1653,6 @@ static void test_CreateIconFromResource(void) ok(icon_info.hbmMask != NULL, "No hbmMask!\n"); }
- /* Clean up. */ - SetLastError(0xdeadbeef); - ret = DestroyCursor(handle); - ok(ret, "DestroyCursor() failed.\n"); - error = GetLastError(); - ok(error == 0xdeadbeef, "Last error: %u\n", error); - /* Rejection of NULL pointer crashes at least on WNT4WSSP6, W2KPROSP4, WXPPROSP3 * * handle = CreateIconFromResource(NULL, ICON_RES_SIZE, TRUE, 0x00030000); @@ -1667,12 +1665,16 @@ static void test_CreateIconFromResource(void) empty_anicursor.frames[0].data.icon_info.idEntries[0].yHotspot = 3; handle = CreateIconFromResource((PBYTE) &empty_anicursor, sizeof(empty_anicursor), FALSE, 0x00030000); ok(handle != NULL, "Create cursor failed.\n"); + ret = DestroyCursor(handle); + ok(ret, "Destroy cursor failed, error %u.\n", GetLastError());
/* Test the animated cursor's information. */ SetLastError(0xdeadbeef); ret = GetIconInfo(handle, &icon_info); + todo_wine ok(ret, "GetIconInfo() failed.\n"); error = GetLastError(); + todo_wine ok(error == 0xdeadbeef, "Last error: %u\n", error);
if (ret) @@ -1685,13 +1687,6 @@ static void test_CreateIconFromResource(void) ok(icon_info.hbmMask != NULL, "No hbmMask!\n"); }
- /* Clean up. */ - SetLastError(0xdeadbeef); - ret = DestroyCursor(handle); - ok(ret, "DestroyCursor() failed.\n"); - error = GetLastError(); - ok(error == 0xdeadbeef, "Last error: %u\n", error); - /* Test creating and destroying a non-shared icon. */ handle = CreateIconFromResourceEx((BYTE *)icon_header, ICON_RES_SIZE, TRUE, 0x00030000, 0, 0, LR_DEFAULTSIZE);
Signed-off-by: Ziqing Hui zhui@codeweavers.com --- dlls/user32/cursoricon.c | 2 +- dlls/user32/tests/cursoricon.c | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-)
diff --git a/dlls/user32/cursoricon.c b/dlls/user32/cursoricon.c index f107255c8c0..827db302a30 100644 --- a/dlls/user32/cursoricon.c +++ b/dlls/user32/cursoricon.c @@ -1592,7 +1592,7 @@ HICON WINAPI CreateIconFromResourceEx( LPBYTE bits, UINT cbSize, HICON WINAPI CreateIconFromResource( LPBYTE bits, UINT cbSize, BOOL bIcon, DWORD dwVersion) { - return CreateIconFromResourceEx( bits, cbSize, bIcon, dwVersion, 0,0,0); + return CreateIconFromResourceEx( bits, cbSize, bIcon, dwVersion, 0, 0, LR_DEFAULTSIZE | LR_SHARED ); }
diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index d73650e08f7..1bbe2591d59 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -1595,10 +1595,8 @@ static void test_CreateIconFromResource(void) /* Test the icon information. */ SetLastError(0xdeadbeef); ret = GetIconInfo(handle, &icon_info); - todo_wine ok(ret, "GetIconInfo() failed.\n"); error = GetLastError(); - todo_wine ok(error == 0xdeadbeef, "Last error: %u\n", error);
if (ret) @@ -1616,14 +1614,10 @@ static void test_CreateIconFromResource(void) ICONINFOEXA infoex; infoex.cbSize = sizeof(infoex); ret = pGetIconInfoExA( handle, &infoex ); - todo_wine ok( ret, "GetIconInfoEx failed err %d\n", GetLastError() ); - if (ret) - { ok( infoex.wResID == 0, "GetIconInfoEx wrong resid %x\n", infoex.wResID ); ok( infoex.szModName[0] == 0, "GetIconInfoEx wrong module %s\n", infoex.szModName ); ok( infoex.szResName[0] == 0, "GetIconInfoEx wrong name %s\n", infoex.szResName ); - } }
/* Test creating an icon. */ @@ -1637,10 +1631,8 @@ static void test_CreateIconFromResource(void) /* Test the icon information. */ SetLastError(0xdeadbeef); ret = GetIconInfo(handle, &icon_info); - todo_wine ok(ret, "GetIconInfo() failed.\n"); error = GetLastError(); - todo_wine ok(error == 0xdeadbeef, "Last error: %u\n", error);
if (ret)