Fixed pri reader features.

This commit is contained in:
Bruce
2025-02-22 23:06:34 +08:00
parent 43dbb6f2d8
commit c111210987
3 changed files with 104 additions and 26 deletions
+16 -1
View File
@@ -312,6 +312,7 @@ HRESULT SetCurrentAppUserModelID (PCWSTR appID)
} }
void ProgressCallback (unsigned progress); void ProgressCallback (unsigned progress);
void ToastPressCallback ();
public ref class MainWnd: public Form 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 title = StrPrintFormatW (GetRCString_cpp (PAGE_4_TITLE).c_str (), m_pkgInfo.getPropertyName ().c_str ());
std::wstring text (L""); std::wstring text (L"");
if (GetLastErrorDetailTextLength ()) text += GetLastErrorDetailText (); 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 #ifdef _DEBUG
//MessageBox::Show (res ? "Toast has create! " : "Toast created failed! "); //MessageBox::Show (res ? "Toast has create! " : "Toast created failed! ");
#endif #endif
@@ -1058,6 +1059,16 @@ public ref class MainWnd: public Form
); );
this->setTaskbarProgress ((unsigned)value); 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 typedef struct _CMDARGUMENT
@@ -1423,6 +1434,10 @@ void ProgressCallback (unsigned progress)
{ {
mainwndPtr->funcSetProgress (progress); mainwndPtr->funcSetProgress (progress);
} }
void ToastPressCallback ()
{
mainwndPtr->launchInstalledApp ();
}
void OutputDebugStringFormatted (const wchar_t* format, ...) void OutputDebugStringFormatted (const wchar_t* format, ...)
{ {
+64 -1
View File
@@ -5,6 +5,27 @@
#include "localeex.h" #include "localeex.h"
#include "PriReader2.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 () int GetDPI ()
{ {
HDC hDC = GetDC (NULL); HDC hDC = GetDC (NULL);
@@ -866,10 +887,24 @@ class PriReader
isMatch = LabelEqual (resname, lpname2); isMatch = LabelEqual (resname, lpname2);
} }
if (!isMatch) 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"); pugi::xml_attribute uriAttr = namedRes.attribute ("uri");
std::string resuri = uriAttr.as_string (); 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) if (isMatch)
{ {
@@ -996,6 +1031,12 @@ class PriReader
isMatch = LabelEqual (resname, lpname2); isMatch = LabelEqual (resname, lpname2);
} }
if (!isMatch) 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"); pugi::xml_attribute uriAttr = namedRes.attribute ("uri");
std::wstring resuri = pugi::as_wide (uriAttr.as_string ()); std::wstring resuri = pugi::as_wide (uriAttr.as_string ());
@@ -1008,6 +1049,14 @@ class PriReader
std::wstring resuri = pugi::as_wide (uriAttr.as_string ()); std::wstring resuri = pugi::as_wide (uriAttr.as_string ());
isMatch = (InStr (resuri, lpname2, true) >= 0); 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) if (isMatch)
{ {
std::map <std::wstring, std::wstring> langmap; std::map <std::wstring, std::wstring> langmap;
@@ -1728,6 +1777,12 @@ class PriReader
LPSTR result = recFindStringValue (subtree, lpMsName, defaultLocaleCode); LPSTR result = recFindStringValue (subtree, lpMsName, defaultLocaleCode);
if (result) return result; 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; return NULL;
} }
// 获取到的指针需要 free 手动释放。 // 获取到的指针需要 free 手动释放。
@@ -1738,6 +1793,14 @@ class PriReader
pugi::xml_node resmap = root.child ("ResourceMap"); pugi::xml_node resmap = root.child ("ResourceMap");
if (!resmap) return NULL; if (!resmap) return NULL;
for (pugi::xml_node subtree = resmap.child ("ResourceMapSubtree"); subtree; subtree = subtree.next_sibling ("ResourceMapSubtree")) 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 (); std::string resMapName = subtree.attribute ("name").as_string ();
if (LabelEqual (resMapName, "Files")) continue; if (LabelEqual (resMapName, "Files")) continue;