mirror of
https://github.com/modernw/AppInstallerForWin8.git
synced 2026-04-11 16:57:18 +10:00
Fixed pri reader features.
This commit is contained in:
@@ -312,6 +312,7 @@ HRESULT SetCurrentAppUserModelID (PCWSTR appID)
|
||||
}
|
||||
|
||||
void ProgressCallback (unsigned progress);
|
||||
void ToastPressCallback ();
|
||||
|
||||
public ref class MainWnd: public Form
|
||||
{
|
||||
@@ -988,7 +989,7 @@ public ref class MainWnd: public Form
|
||||
std::wstring title = StrPrintFormatW (GetRCString_cpp (PAGE_4_TITLE).c_str (), m_pkgInfo.getPropertyName ().c_str ());
|
||||
std::wstring text (L"");
|
||||
if (GetLastErrorDetailTextLength ()) text += GetLastErrorDetailText ();
|
||||
bool res = CreateToastNotification (m_idenName, title.c_str (), text.c_str (), NULL, m_pkgInfo.getPropertyLogoIStream ());
|
||||
bool res = CreateToastNotification (m_idenName, title.c_str (), text.c_str (), &ToastPressCallback, m_pkgInfo.getPropertyLogoIStream ());
|
||||
#ifdef _DEBUG
|
||||
//MessageBox::Show (res ? "Toast has create! " : "Toast created failed! ");
|
||||
#endif
|
||||
@@ -1058,6 +1059,16 @@ public ref class MainWnd: public Form
|
||||
);
|
||||
this->setTaskbarProgress ((unsigned)value);
|
||||
}
|
||||
bool launchInstalledApp ()
|
||||
{
|
||||
if (page != 4) return false;
|
||||
else
|
||||
{
|
||||
if (!reader.isPackageApplication ()) return false;
|
||||
}
|
||||
this->Button1_PressEvent ();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
typedef struct _CMDARGUMENT
|
||||
@@ -1423,6 +1434,10 @@ void ProgressCallback (unsigned progress)
|
||||
{
|
||||
mainwndPtr->funcSetProgress (progress);
|
||||
}
|
||||
void ToastPressCallback ()
|
||||
{
|
||||
mainwndPtr->launchInstalledApp ();
|
||||
}
|
||||
|
||||
void OutputDebugStringFormatted (const wchar_t* format, ...)
|
||||
{
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2006-2025 Arseny Kapoulkine
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2006-2025 Arseny Kapoulkine
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@@ -5,6 +5,27 @@
|
||||
#include "localeex.h"
|
||||
#include "PriReader2.h"
|
||||
|
||||
template <typename CharT> std::basic_string <CharT> replace_substring
|
||||
(
|
||||
const std::basic_string <CharT> &str,
|
||||
const std::basic_string <CharT> &from,
|
||||
const std::basic_string <CharT> &to
|
||||
)
|
||||
{
|
||||
if (from.empty ()) return str;
|
||||
std::basic_string <CharT> result;
|
||||
size_t pos = 0;
|
||||
size_t start_pos;
|
||||
while ((start_pos = str.find (from, pos)) != std::basic_string<CharT>::npos)
|
||||
{
|
||||
result.append (str, pos, start_pos - pos);
|
||||
result.append (to);
|
||||
pos = start_pos + from.length ();
|
||||
}
|
||||
result.append (str, pos, str.length () - pos);
|
||||
return result;
|
||||
}
|
||||
|
||||
int GetDPI ()
|
||||
{
|
||||
HDC hDC = GetDC (NULL);
|
||||
@@ -866,10 +887,24 @@ class PriReader
|
||||
isMatch = LabelEqual (resname, lpname2);
|
||||
}
|
||||
if (!isMatch)
|
||||
{
|
||||
std::string objstr = std::regex_replace (std::string (lpMsName), pattern, "");
|
||||
std::string lpname2 = PathFindFileNameA (objstr.c_str ());
|
||||
isMatch = LabelEqual (resname, lpname2);
|
||||
}
|
||||
if (!isMatch)
|
||||
{
|
||||
pugi::xml_attribute uriAttr = namedRes.attribute ("uri");
|
||||
std::string resuri = uriAttr.as_string ();
|
||||
isMatch = (InStr (resuri, resname) >= 0);
|
||||
isMatch = (InStr (resuri, lpMsName, true) >= 0);
|
||||
}
|
||||
if (!isMatch)
|
||||
{
|
||||
pugi::xml_attribute uriAttr = namedRes.attribute ("uri");
|
||||
std::string resuri = uriAttr.as_string ();
|
||||
std::string objstr = std::regex_replace (std::string (lpMsName), pattern, "");
|
||||
objstr = replace_substring <char> (objstr, "\\", "/");
|
||||
isMatch = (InStr (resuri, objstr, true) >= 0);
|
||||
}
|
||||
if (isMatch)
|
||||
{
|
||||
@@ -996,6 +1031,12 @@ class PriReader
|
||||
isMatch = LabelEqual (resname, lpname2);
|
||||
}
|
||||
if (!isMatch)
|
||||
{
|
||||
std::wstring objstr = std::regex_replace (std::wstring (lpMsName), pattern, L"");
|
||||
std::wstring lpname2 = PathFindFileNameW (objstr.c_str ());
|
||||
isMatch = LabelEqual (resname, lpname2);
|
||||
}
|
||||
if (!isMatch)
|
||||
{
|
||||
pugi::xml_attribute uriAttr = namedRes.attribute ("uri");
|
||||
std::wstring resuri = pugi::as_wide (uriAttr.as_string ());
|
||||
@@ -1008,6 +1049,14 @@ class PriReader
|
||||
std::wstring resuri = pugi::as_wide (uriAttr.as_string ());
|
||||
isMatch = (InStr (resuri, lpname2, true) >= 0);
|
||||
}
|
||||
if (!isMatch)
|
||||
{
|
||||
pugi::xml_attribute uriAttr = namedRes.attribute ("uri");
|
||||
std::wstring resuri = pugi::as_wide (uriAttr.as_string ());
|
||||
std::wstring objstr = std::regex_replace (std::wstring (lpMsName), pattern, L"");
|
||||
objstr = replace_substring <WCHAR> (objstr, L"\\", L"/");
|
||||
isMatch = (InStr (resuri, objstr, true) >= 0);
|
||||
}
|
||||
if (isMatch)
|
||||
{
|
||||
std::map <std::wstring, std::wstring> langmap;
|
||||
@@ -1728,6 +1777,12 @@ class PriReader
|
||||
LPSTR result = recFindStringValue (subtree, lpMsName, defaultLocaleCode);
|
||||
if (result) return result;
|
||||
}
|
||||
for (pugi::xml_node subtree = resmap.child ("ResourceMapSubtree"); subtree; subtree = subtree.next_sibling ("ResourceMapSubtree"))
|
||||
{
|
||||
std::string resMapName = subtree.attribute ("name").as_string ();
|
||||
LPSTR result = recFindStringValue (subtree, lpMsName, defaultLocaleCode);
|
||||
if (result) return result;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
// 获取到的指针需要 free 手动释放。
|
||||
@@ -1738,6 +1793,14 @@ class PriReader
|
||||
pugi::xml_node resmap = root.child ("ResourceMap");
|
||||
if (!resmap) return NULL;
|
||||
for (pugi::xml_node subtree = resmap.child ("ResourceMapSubtree"); subtree; subtree = subtree.next_sibling ("ResourceMapSubtree"))
|
||||
{
|
||||
std::string resMapName = subtree.attribute ("name").as_string ();
|
||||
if (LabelEqual (resMapName, "Files")) continue;
|
||||
if (!LabelEqual (resMapName, "resources")) continue;
|
||||
LPWSTR result = recFindStringValue (subtree, lpMsName, defaultLocaleCode);
|
||||
if (result && lstrlenW (result) > 0) return result;
|
||||
}
|
||||
for (pugi::xml_node subtree = resmap.child ("ResourceMapSubtree"); subtree; subtree = subtree.next_sibling ("ResourceMapSubtree"))
|
||||
{
|
||||
std::string resMapName = subtree.attribute ("name").as_string ();
|
||||
if (LabelEqual (resMapName, "Files")) continue;
|
||||
|
||||
Reference in New Issue
Block a user