Updates for WebUI:

· [Important] Fixed the destruction issue with PriReader (caused by incorrect pointer types leading to unexecuted object destruction tasks).
· [Important] Added a program execution selection interface for packages containing multiple applications (still using WebUI).
 Issue: Since the selection window is set to close when losing focus, checking the "Launch when ready" option after successful installation causes the pop-up window to disappear when a Toast notification appears (due to focus loss). Currently, the selection window can only be displayed by clicking a button.
· [Optimization] Reduced the creation of PriReader objects to lower memory and storage consumption.
(Translated by DeepSeek)
This commit is contained in:
Bruce
2025-03-02 00:33:09 +08:00
parent ff0cebc7cc
commit 949759ffe9
14 changed files with 2445 additions and 60 deletions

View File

@@ -31,4 +31,33 @@ LPSTR StreamToBase64 (HISTREAM ifile)
if (!lpszStr) return NULL;
lstrcpyA (lpszStr, res.c_str ());
return lpszStr;
}
}
LPWSTR StreamToBase64W (HISTREAM ifile)
{
if (!ifile) return NULL;
IStream *pStream = (IStream *)ifile;
LARGE_INTEGER liZero = {};
pStream->Seek (liZero, STREAM_SEEK_SET, nullptr);
STATSTG statstg;
pStream->Stat (&statstg, STATFLAG_NONAME);
ULARGE_INTEGER uliSize = statstg.cbSize;
std::vector<BYTE> buffer (uliSize.QuadPart);
ULONG bytesRead;
pStream->Read (buffer.data (), static_cast<ULONG>(buffer.size ()), &bytesRead);
DWORD base64Size = 0;
if (!CryptBinaryToStringW (buffer.data (), bytesRead, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, nullptr, &base64Size))
{
return NULL;
}
std::vector <WCHAR> base64Buffer (base64Size);
if (!CryptBinaryToStringW (buffer.data (), bytesRead, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, base64Buffer.data (), &base64Size))
{
return NULL;
}
std::wstring res = std::wstring (base64Buffer.begin (), base64Buffer.end ());
LPWSTR lpszStr = (LPWSTR)calloc (res.capacity (), sizeof (WCHAR));
if (!lpszStr) return NULL;
lstrcpyW (lpszStr, res.c_str ());
return lpszStr;
}

View File

@@ -14,3 +14,5 @@ typedef HANDLE HISTREAM;
typedef char *LPSTR;
extern "C" BASE64IMG_API LPSTR StreamToBase64 (HISTREAM ifile);
extern "C" BASE64IMG_API LPWSTR StreamToBase64W (HISTREAM ifile);