IconExtraction.h (1557B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <vector> 5 #include <winget/Manifest.h> 6 7 namespace AppInstaller::Repository 8 { 9 struct ExtractedIconInfo 10 { 11 std::vector<BYTE> IconContent; 12 std::vector<BYTE> IconSha256; 13 AppInstaller::Manifest::IconFileTypeEnum IconFileType = AppInstaller::Manifest::IconFileTypeEnum::Unknown; 14 AppInstaller::Manifest::IconThemeEnum IconTheme = AppInstaller::Manifest::IconThemeEnum::Unknown; 15 AppInstaller::Manifest::IconResolutionEnum IconResolution = AppInstaller::Manifest::IconResolutionEnum::Unknown; 16 }; 17 18 // The usage of iconIndex is same as usage in ExtractIconEx at 19 // https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-extracticonexw 20 // The icon index usage is basically: 21 // 0, 1, 2 means zero-based index of the first icon to extract. 22 // -1, -2, -3 means extract icon whose resource name is 1, 2, 3 etc 23 std::vector<BYTE> ExtractIconFromBinaryFile(const std::filesystem::path binaryPath, int iconIndex = 0); 24 25 // Extracts the app icon given the app's product code. 26 // This method uses similar logic for retrieving icon as app list in settings page. 27 // This method returns empty if only default icons would be picked. 28 // This method returns contents of .ico icons. 29 std::vector<ExtractedIconInfo> ExtractIconFromArpEntry(const std::string& productCode, AppInstaller::Manifest::ScopeEnum scope = AppInstaller::Manifest::ScopeEnum::Unknown); 30 }