mirror of
https://github.com/modernw/AppInstallerForWin8.git
synced 2026-04-11 16:57:18 +10:00
Console App: Remove Codes about Store Logo and Base 64
This commit is contained in:
@@ -71,14 +71,14 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ShoutcutCreater;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;$(IncludePath)</IncludePath>
|
||||
<IncludePath>E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ShoutcutCreater;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\Base64Img;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ShoutcutCreater;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;$(IncludePath)</IncludePath>
|
||||
<IncludePath>E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\AppLauncher;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\CertificateManager;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PackageManagerAdd;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\PriReader2;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ShoutcutCreater;E:\Profiles\Bruce\Documents\Visual Studio 2015\Projects\AppInstaller\ToastNotification;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
@@ -95,7 +95,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)Base64Img.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@@ -129,7 +129,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)Base64Img.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>shlwapi.lib;dwmapi.lib;crypt32.lib;$(OutDir)PackageManager.lib;$(OutDir)AppLauncher.lib;$(OutDir)ToastNotification.lib;$(OutDir)PriReader2.lib;$(OutDir)CertificateManager.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@@ -152,7 +152,6 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="base64logo.h" />
|
||||
<ClInclude Include="initread.h" />
|
||||
<ClInclude Include="localeex.h" />
|
||||
<ClInclude Include="pkgcode.h" />
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="base64logo.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="initread.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -1,291 +0,0 @@
|
||||
#pragma once
|
||||
#include "Base64Img.h"
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <regex>
|
||||
#include "pkgcode.h"
|
||||
#include "priread.h"
|
||||
|
||||
std::string GetFileNameWithoutExtension (LPCSTR filePath)
|
||||
{
|
||||
char pathCopy [MAX_PATH];
|
||||
lstrcpynA (pathCopy, filePath, MAX_PATH);
|
||||
char *fileName = PathFindFileNameA (pathCopy);
|
||||
PathRemoveExtensionA (fileName);
|
||||
return std::string (fileName);
|
||||
}
|
||||
std::wstring GetFileNameWithoutExtension (LPCWSTR filePath)
|
||||
{
|
||||
wchar_t pathCopy [MAX_PATH];
|
||||
lstrcpynW (pathCopy, filePath, MAX_PATH);
|
||||
wchar_t *fileName = PathFindFileNameW (pathCopy);
|
||||
PathRemoveExtensionW (fileName);
|
||||
return std::wstring (fileName);
|
||||
}
|
||||
std::string GetFileNameWithoutExtension (const std::string &filePath)
|
||||
{
|
||||
return GetFileNameWithoutExtension (filePath.c_str ());
|
||||
}
|
||||
std::wstring GetFileNameWithoutExtension (const std::wstring &filePath)
|
||||
{
|
||||
return GetFileNameWithoutExtension (filePath.c_str ());
|
||||
}
|
||||
|
||||
std::string GetLogoBase64FromReader (PackageReader &reader, IStream **getOutput = NULL)
|
||||
{
|
||||
if (!&reader) return std::string ("");
|
||||
if (!reader.isAvailable ()) return std::string ("");
|
||||
std::wstring logoPath = reader.getPropertyLogo ();
|
||||
if (logoPath.empty () || logoPath.length () == 0) return std::string ("");
|
||||
PriReader pri (reader.getPriFileStream ());
|
||||
if (pri.isAvailable ())
|
||||
{
|
||||
std::wstring logoPathFromPri = pri.findFilePathValue (logoPath);
|
||||
if (!logoPathFromPri.empty () && logoPath.length () > 0) logoPath = logoPathFromPri;
|
||||
}
|
||||
IStream *imgfile = reader.extractFileToStream (logoPath);
|
||||
if (getOutput) *getOutput = imgfile;
|
||||
if (!imgfile)
|
||||
{
|
||||
std::wstring fileName = GetFileNameWithoutExtension (logoPath);
|
||||
IAppxPackageReader *appxreader = reader.getAppxPackageReader ();
|
||||
CComPtr <IAppxFilesEnumerator> fe = NULL;
|
||||
HRESULT hr = appxreader->GetPayloadFiles (&fe);
|
||||
if (SUCCEEDED (hr) && fe)
|
||||
{
|
||||
std::vector <std::wstring> files;
|
||||
BOOL hasCurrent = FALSE;
|
||||
hr = fe->GetHasCurrent (FALSE);
|
||||
while (SUCCEEDED (hr) && hasCurrent)
|
||||
{
|
||||
CComPtr <IAppxFile> ifile = NULL;
|
||||
hr = fe->GetCurrent (&ifile);
|
||||
if (SUCCEEDED (hr) && ifile)
|
||||
{
|
||||
LPWSTR lpstr = NULL;
|
||||
if (SUCCEEDED (ifile->GetName (&lpstr)) && lpstr)
|
||||
{
|
||||
std::wstring strWillSearch = StringToUpper (StringTrim (lpstr));
|
||||
std::wstring strWillToSearch = StringToUpper (StringTrim (fileName));
|
||||
if (StrStrW (strWillSearch.c_str (), strWillToSearch.c_str ()))
|
||||
{
|
||||
bool isFind = LabelEqual (PathFindExtensionW (lpstr), L".png");
|
||||
if (!isFind) isFind = LabelEqual (PathFindExtensionW (lpstr), L".jpg");
|
||||
if (!isFind) isFind = LabelEqual (PathFindExtensionW (lpstr), L".jpeg");
|
||||
if (!isFind) isFind = LabelEqual (PathFindExtensionW (lpstr), L".bmp");
|
||||
if (isFind)
|
||||
{
|
||||
std::wstring temp (L"");
|
||||
if (lpstr) temp += lpstr;
|
||||
if (temp.length () > 0) push_no_repeat (files, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
bool isFindSuit = false;
|
||||
{
|
||||
std::map <int, std::wstring> scaleFiles;
|
||||
std::wregex pattern (L"(scale-(\\d+))");
|
||||
for (auto it : files)
|
||||
{
|
||||
if (StrStrW (it.c_str (), L"contrast-")) continue;
|
||||
std::wsmatch match;
|
||||
if (std::regex_search (it, match, pattern))
|
||||
{
|
||||
int temp = StrToIntW (match [1].str ().c_str ());
|
||||
if (!temp)
|
||||
{
|
||||
scaleFiles [temp] = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scaleFiles.find (GetDPI ()) != scaleFiles.end ())
|
||||
{
|
||||
isFindSuit = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isFindScale = false;
|
||||
for (auto it : scaleFiles)
|
||||
{
|
||||
if (it.first >= GetDPI ())
|
||||
{
|
||||
isFindScale = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isFindScale)
|
||||
{
|
||||
for (auto it : scaleFiles)
|
||||
{
|
||||
if (it.first >= 100)
|
||||
{
|
||||
isFindScale = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isFindScale)
|
||||
{
|
||||
for (auto it : scaleFiles)
|
||||
{
|
||||
isFindScale = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
break;
|
||||
}
|
||||
}
|
||||
isFindSuit = isFindScale;
|
||||
}
|
||||
}
|
||||
if (!isFindSuit)
|
||||
{
|
||||
std::map <int, std::wstring> scaleFiles;
|
||||
std::wregex pattern (L"(scale-(\\d+))");
|
||||
for (auto it : files)
|
||||
{
|
||||
if (StrStrW (it.c_str (), L"contrast-white")) continue;
|
||||
std::wsmatch match;
|
||||
if (std::regex_search (it, match, pattern))
|
||||
{
|
||||
int temp = StrToIntW (match [1].str ().c_str ());
|
||||
if (!temp)
|
||||
{
|
||||
scaleFiles [temp] = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scaleFiles.find (GetDPI ()) != scaleFiles.end ())
|
||||
{
|
||||
isFindSuit = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isFindScale = false;
|
||||
for (auto it : scaleFiles)
|
||||
{
|
||||
if (it.first >= GetDPI ())
|
||||
{
|
||||
isFindScale = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isFindScale)
|
||||
{
|
||||
for (auto it : scaleFiles)
|
||||
{
|
||||
if (it.first >= 100)
|
||||
{
|
||||
isFindScale = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isFindScale)
|
||||
{
|
||||
for (auto it : scaleFiles)
|
||||
{
|
||||
isFindScale = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
break;
|
||||
}
|
||||
}
|
||||
isFindSuit = isFindScale;
|
||||
}
|
||||
}
|
||||
if (!isFindSuit)
|
||||
{
|
||||
std::map <int, std::wstring> scaleFiles;
|
||||
std::wregex pattern (L"(scale-(\\d+))");
|
||||
for (auto it : files)
|
||||
{
|
||||
if (StrStrW (it.c_str (), L"contrast-black")) continue;
|
||||
std::wsmatch match;
|
||||
if (std::regex_search (it, match, pattern))
|
||||
{
|
||||
int temp = StrToIntW (match [1].str ().c_str ());
|
||||
if (!temp)
|
||||
{
|
||||
scaleFiles [temp] = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (scaleFiles.find (GetDPI ()) != scaleFiles.end ())
|
||||
{
|
||||
isFindSuit = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isFindScale = false;
|
||||
for (auto it : scaleFiles)
|
||||
{
|
||||
if (it.first >= GetDPI ())
|
||||
{
|
||||
isFindScale = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isFindScale)
|
||||
{
|
||||
for (auto it : scaleFiles)
|
||||
{
|
||||
if (it.first >= 100)
|
||||
{
|
||||
isFindScale = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isFindScale)
|
||||
{
|
||||
for (auto it : scaleFiles)
|
||||
{
|
||||
isFindScale = true;
|
||||
logoPath = scaleFiles [GetDPI ()];
|
||||
break;
|
||||
}
|
||||
}
|
||||
isFindSuit = isFindScale;
|
||||
}
|
||||
}
|
||||
if (!isFindSuit)
|
||||
{
|
||||
for (auto it : files)
|
||||
{
|
||||
logoPath = std::wstring (L"") + it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
imgfile = reader.extractFileToStream (logoPath);
|
||||
}
|
||||
if (getOutput) *getOutput = imgfile;
|
||||
if (!imgfile) return std::string ("");
|
||||
std::string b64res ("");
|
||||
LPSTR szRes = StreamToBase64 (imgfile);
|
||||
if (!getOutput)
|
||||
{
|
||||
if (imgfile)
|
||||
{
|
||||
imgfile->Release ();
|
||||
imgfile = NULL;
|
||||
}
|
||||
}
|
||||
if (!szRes) return b64res;
|
||||
if (szRes) b64res += szRes;
|
||||
free (szRes);
|
||||
if (b64res.length () > 0)
|
||||
{
|
||||
b64res = "data:image/png;base64," + b64res;
|
||||
}
|
||||
return b64res;
|
||||
}
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "resource.h"
|
||||
#include "res2.h"
|
||||
#include "PackageManager.h"
|
||||
#include "base64logo.h"
|
||||
#include "AppLauncher.h"
|
||||
#include "ToastNotification.h"
|
||||
#include "pkginfo.h"
|
||||
@@ -509,8 +508,8 @@ void TaskInstallPackage ()
|
||||
{
|
||||
ReadPackageInfo ();
|
||||
wcout << StrPrintFormatW (GetRCString_cpp (PAGE_2_TITLE).c_str (), g_pkgInfo.getPropertyName ().c_str ()) << endl;
|
||||
wcout << GetRCString_cpp (PAGE_2_INSTALL);
|
||||
LoadCert ();
|
||||
wcout << GetRCString_cpp (PAGE_2_INSTALL);
|
||||
InstallPackage ();
|
||||
}
|
||||
else
|
||||
|
||||
@@ -26,8 +26,6 @@ struct PackageInfomation
|
||||
std::wstring name = L"";
|
||||
std::wstring description = L"";
|
||||
std::wstring publisher = L"";
|
||||
std::string logoBase64 = "";
|
||||
CComPtr <IStream> logoStream = NULL;
|
||||
} properties;
|
||||
std::vector <appmap> applications;
|
||||
std::vector <std::wstring> capabilities;
|
||||
@@ -59,23 +57,30 @@ struct PackageInfomation
|
||||
reader.getIdentityProcessorArchitecture (this->identities.architectures);
|
||||
reader.getResourceLanguages (this->resources.languages);
|
||||
std::sort (this->resources.languages.begin (), this->resources.languages.end ());
|
||||
this->properties.name = reader.getPropertyName ();
|
||||
this->properties.publisher = reader.getPropertyPublisher ();
|
||||
this->properties.description = reader.getPropertyDescription ();
|
||||
if (isMsResourceLabel (this->properties.name) ||
|
||||
isMsResourceLabel (this->properties.publisher) ||
|
||||
isMsResourceLabel (this->properties.description))
|
||||
{
|
||||
if (pri.create (reader.getPriFileStream ()))
|
||||
{
|
||||
std::wstring temp = reader.getPropertyName ();
|
||||
std::wstring temp = this->properties.name;
|
||||
if (isMsResourceLabel (temp))
|
||||
{
|
||||
std::wstring getres = pri.findStringValue (temp);
|
||||
if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres;
|
||||
}
|
||||
this->properties.name = temp;
|
||||
temp = reader.getPropertyDescription ();
|
||||
temp = this->properties.publisher;
|
||||
if (isMsResourceLabel (temp))
|
||||
{
|
||||
std::wstring getres = pri.findStringValue (temp);
|
||||
if (!getres.empty () && getres.length () > 0) temp = std::wstring (L"") + getres;
|
||||
}
|
||||
this->properties.description = temp;
|
||||
temp = reader.getPropertyPublisher ();
|
||||
temp = this->properties.description;
|
||||
if (isMsResourceLabel (temp))
|
||||
{
|
||||
std::wstring getres = pri.findStringValue (temp);
|
||||
@@ -83,13 +88,7 @@ struct PackageInfomation
|
||||
}
|
||||
this->properties.publisher = temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->properties.name = reader.getPropertyName ();
|
||||
this->properties.description = reader.getPropertyDescription ();
|
||||
this->properties.publisher = reader.getPropertyPublisher ();
|
||||
}
|
||||
this->properties.logoBase64 = GetLogoBase64FromReader (reader, &this->properties.logoStream);
|
||||
this->prerequisites.osMinVersion = reader.getPrerequisiteOSMinVersion ();
|
||||
reader.getApplications (this->applications);
|
||||
reader.getCapabilities (capabilities);
|
||||
@@ -105,8 +104,6 @@ struct PackageInfomation
|
||||
this->properties.name = L"";
|
||||
this->properties.description = L"";
|
||||
this->properties.publisher = L"";
|
||||
this->properties.logoBase64 = "";
|
||||
if (this->properties.logoStream) { this->properties.logoStream.Release (); this->properties.logoStream = nullptr; }
|
||||
this->resources.languages.clear ();
|
||||
this->prerequisites.osMinVersion = VERSION (0);
|
||||
this->applications.clear ();
|
||||
@@ -138,9 +135,6 @@ struct PackageInfomation
|
||||
std::wstring getPropertyName () { return this->properties.name; }
|
||||
std::wstring getPropertyDescription () { return this->properties.description; }
|
||||
std::wstring getPropertyPublisher () { return this->properties.publisher; }
|
||||
std::string getPropertyLogoBase64 () { return this->properties.logoBase64; }
|
||||
// 无需手动释放
|
||||
IStream *getPropertyLogoIStream () { return this->properties.logoStream; }
|
||||
// 失败返回都为 0 的版本号
|
||||
VERSION getPrerequisiteOSMinVersion () { return this->prerequisites.osMinVersion; }
|
||||
// 判断当前包是否为应用包而不是资源包或依赖项。如果为捆绑包的话判断是否子包中存在应用包。
|
||||
|
||||
Reference in New Issue
Block a user