mirror of
https://github.com/modernw/AppInstallerForWin8.git
synced 2026-04-11 16:57:18 +10:00
· [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)
64 lines
2.1 KiB
C++
64 lines
2.1 KiB
C++
// Base64Img.cpp : 定义 DLL 应用程序的导出函数。
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "Base64Img.h"
|
|
|
|
LPSTR StreamToBase64 (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 (!CryptBinaryToStringA (buffer.data (), bytesRead, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, nullptr, &base64Size))
|
|
{
|
|
return NULL;
|
|
}
|
|
std::vector<char> base64Buffer (base64Size);
|
|
if (!CryptBinaryToStringA (buffer.data (), bytesRead, CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF, base64Buffer.data (), &base64Size))
|
|
{
|
|
return NULL;
|
|
}
|
|
std::string res = std::string (base64Buffer.begin (), base64Buffer.end ());
|
|
LPSTR lpszStr = (LPSTR)calloc (res.capacity (), sizeof (char));
|
|
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;
|
|
}
|