4 Commits

Author SHA1 Message Date
Bruce
c414259e7a Update Version 2025-04-19 18:58:04 +08:00
Bruce
478d2580da Fixed Save Position 2025-04-19 18:53:12 +08:00
Bruce
e2d78df375 (None) 2025-03-14 23:11:22 +08:00
Bruce
99df99dd9f Fixed HTML 2025-03-02 22:26:40 +08:00
9 changed files with 458 additions and 129 deletions

View File

@@ -114,8 +114,8 @@ IDR_MANIFEST1 RT_MANIFEST "res/manifest.xml"
// //
IDR_VERSION_ZH_CN VERSIONINFO IDR_VERSION_ZH_CN VERSIONINFO
FILEVERSION 1,0,1,9 FILEVERSION 1,0,1,11
PRODUCTVERSION 1,0,1,9 PRODUCTVERSION 1,0,1,11
FILEFLAGSMASK 0x0L FILEFLAGSMASK 0x0L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@@ -132,9 +132,9 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Bruce Winter" VALUE "CompanyName", "Bruce Winter"
VALUE "FileDescription", "应用安装程序" VALUE "FileDescription", "应用安装程序"
VALUE "FileVersion", "1.0.1.9" VALUE "FileVersion", "1.0.1.11"
VALUE "LegalCopyright", "\\xA9Bruce Winter. All rights reserved." VALUE "LegalCopyright", "\\xA9Bruce Winter. All rights reserved."
VALUE "ProductVersion", "1.0.1.9" VALUE "ProductVersion", "1.0.1.11"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
@@ -144,8 +144,8 @@ BEGIN
END END
IDR_VERSION_EN_US VERSIONINFO IDR_VERSION_EN_US VERSIONINFO
FILEVERSION 1,0,1,9 FILEVERSION 1,0,1,11
PRODUCTVERSION 1,0,1,9 PRODUCTVERSION 1,0,1,11
FILEFLAGSMASK 0x0L FILEFLAGSMASK 0x0L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@@ -162,9 +162,9 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Bruce Winter" VALUE "CompanyName", "Bruce Winter"
VALUE "FileDescription", "App Installer" VALUE "FileDescription", "App Installer"
VALUE "FileVersion", "1.0.1.9" VALUE "FileVersion", "1.0.1.11"
VALUE "LegalCopyright", "\\xA9Bruce Winter. All rights reserved." VALUE "LegalCopyright", "\\xA9Bruce Winter. All rights reserved."
VALUE "ProductVersion", "1.0.1.9" VALUE "ProductVersion", "1.0.1.11"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
@@ -241,9 +241,12 @@ BEGIN
APPLIST_WINTITLE "应用选择列表" APPLIST_WINTITLE "应用选择列表"
APPLIST_TITLE "你要从哪个应用开始?" APPLIST_TITLE "你要从哪个应用开始?"
APPLIST_BUTTON_CANCEL "取消" APPLIST_BUTTON_CANCEL "取消"
SHORTCUT_SETTINGS "设置"
SHORTCUT_UNINSTALL "删除 应用安装程序"
SHORTCUT_UPDATE "更新 App Installer"
CLHELP_1 "命令行参数说明:\n\n" CLHELP_1 "命令行参数说明:\n\n"
CLHELP_2 "\t/?, /Help\n\t显示帮助窗口 (命令行参数说明)\n\n" CLHELP_2 "\t/?, /Help\n\t显示帮助窗口 (命令行参数说明)\n\n"
CLHELP_3 "\t/DisableFrame\n\t禁止使用自绘的窗口边框\n\n" CLHELP_3 "\t/DisableFrame\n\t禁止使用自绘的窗口边框 (仅用于易程序)\n\n"
CLHELP_4 "\t/Win32Window\n\t不使用 WebUI改用 Win32 窗口\n\n" CLHELP_4 "\t/Win32Window\n\t不使用 WebUI改用 Win32 窗口\n\n"
CLHELP_5 "\t/Silent\n\t一般情况下会自动安装安装完成后在几秒后结束\n\n" CLHELP_5 "\t/Silent\n\t一般情况下会自动安装安装完成后在几秒后结束\n\n"
CLHELP_6 "\t/VerySilent\n\t静默安装安装时不会显示任何信息安装任务完成后自动结束\n\n" CLHELP_6 "\t/VerySilent\n\t静默安装安装时不会显示任何信息安装任务完成后自动结束\n\n"
@@ -269,6 +272,9 @@ END
STRINGTABLE STRINGTABLE
BEGIN BEGIN
CLHELP_7 "\t/NoGUI\n\t使用 WSAppPkgIns 安装。安装时会弹出命令行窗口,安装完成后需手动关闭窗口\n\n" CLHELP_7 "\t/NoGUI\n\t使用 WSAppPkgIns 安装。安装时会弹出命令行窗口,安装完成后需手动关闭窗口\n\n"
CLHELP_8 "\t/EnableFrame\n\t使用自绘的窗口边框 (仅用于易程序)\n\n"
CLHELP_9 "\t/EProgram\n\t使用易的 WebUI\n\n"
CLHELP_10 "\t/Console\n\t使用命令行版的 应用安装程序 (其实建议直接使用 AppInstallerConsole.exe 才更方便看输入输出)\n\n"
END END
STRINGTABLE STRINGTABLE
@@ -409,9 +415,12 @@ BEGIN
APPLIST_WINTITLE "App Select List" APPLIST_WINTITLE "App Select List"
APPLIST_TITLE "Which app do you want to start with?" APPLIST_TITLE "Which app do you want to start with?"
APPLIST_BUTTON_CANCEL "Cancel" APPLIST_BUTTON_CANCEL "Cancel"
SHORTCUT_SETTINGS "Settings"
SHORTCUT_UNINSTALL "Delete App Installer"
SHORTCUT_UPDATE "Update App Installer"
CLHELP_1 "Usage:\n\n" CLHELP_1 "Usage:\n\n"
CLHELP_2 "\t/?, /Help\n\tDisplay help window (command line parameter description).\n\n" CLHELP_2 "\t/?, /Help\n\tDisplay help window (command line parameter description).\n\n"
CLHELP_3 "\t/DisableFrame\n\tDisable the use of self-drawn window borders.\n\n" CLHELP_3 "\t/DisableFrame\n\tDisable the use of self-drawn window borders. (Only use for E program.)\n\n"
CLHELP_4 "\t/Win32Window\n\tDo not use WebUI, use Win32 window instead.\n\n" CLHELP_4 "\t/Win32Window\n\tDo not use WebUI, use Win32 window instead.\n\n"
CLHELP_5 "\t/Silent\n\tUnder normal circumstances, it will be automatically installed and will end after a few seconds.\n\n" CLHELP_5 "\t/Silent\n\tUnder normal circumstances, it will be automatically installed and will end after a few seconds.\n\n"
CLHELP_6 "\t/VerySilent\n\tSilent installation, no information will be displayed during installation, and the installation task will automatically end after completion.\n\n" CLHELP_6 "\t/VerySilent\n\tSilent installation, no information will be displayed during installation, and the installation task will automatically end after completion.\n\n"
@@ -429,6 +438,9 @@ END
STRINGTABLE STRINGTABLE
BEGIN BEGIN
CLHELP_7 "\t/NoGUI\n\tUse WSAppPkgIns to install. A command line window will pop up during installation, and you need to manually close the window after installation.\n\n" CLHELP_7 "\t/NoGUI\n\tUse WSAppPkgIns to install. A command line window will pop up during installation, and you need to manually close the window after installation.\n\n"
CLHELP_8 "\t/EnableFrame\n\tEnable the use of self-drawn window borders. (Only use for E program.)\n\n"
CLHELP_9 "\t/EProgram\n\tUse E WebUI program.\n\n"
CLHELP_10 "\t/Console\n\tUse the command line version of the application installer (it is actually recommended to use AppInstallerConsole.exe directly for easier viewing of input and output)\n\n"
END END
STRINGTABLE STRINGTABLE

View File

@@ -142,6 +142,7 @@
<AdditionalManifestFiles>app.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles> <AdditionalManifestFiles>app.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
<InputResourceManifests> <InputResourceManifests>
</InputResourceManifests> </InputResourceManifests>
<EnableDpiAwareness>false</EnableDpiAwareness>
</Manifest> </Manifest>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">

View File

@@ -1,17 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<application> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<!-- Windows 10 --> <application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 --> <!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows Vista --> <!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 --> <!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 --> <!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a4e38}"/>
</application> </application>
</compatibility> </compatibility>
<!-- 高DPI感知配置兼容旧版SDK -->
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly> </assembly>

View File

@@ -29,6 +29,7 @@ using namespace System;
using namespace System::Windows::Forms; using namespace System::Windows::Forms;
using namespace System::Threading; using namespace System::Threading;
using namespace msclr::interop; using namespace msclr::interop;
using namespace System::Runtime::InteropServices;
int GetScreenWidth () int GetScreenWidth ()
{ {
@@ -44,6 +45,9 @@ int GetScreenHeight ()
#define toBool(_String_Managed_Object_) Boolean::Parse (_String_Managed_Object_) #define toBool(_String_Managed_Object_) Boolean::Parse (_String_Managed_Object_)
#define toDateTime(_String_Managed_Object_) DateTime::Parse (_String_Managed_Object_) #define toDateTime(_String_Managed_Object_) DateTime::Parse (_String_Managed_Object_)
extern int iDpi = GetDPI ();
extern double dDpi = iDpi * 0.01;
String ^GetRCString_NET (UINT resID) String ^GetRCString_NET (UINT resID)
{ {
size_t bufferSize = 256; size_t bufferSize = 256;
@@ -206,9 +210,6 @@ void SetWebBrowserEmulation ()
System::Runtime::InteropServices::Marshal::FreeHGlobal (appNamePtr); System::Runtime::InteropServices::Marshal::FreeHGlobal (appNamePtr);
} }
#include <windows.h>
#include <string>
bool IsIeVersion10 () bool IsIeVersion10 ()
{ {
HKEY hKey; HKEY hKey;
@@ -335,43 +336,27 @@ void OutputDebugStringFormatted (const wchar_t* format, ...);
public ref class AppWindow: public Form public ref class AppWindow: public Form
{ {
private: private:
WebBrowser ^webUI; System::Windows::Forms::WebBrowser ^webUI;
std::vector <appmap> *appItems = new std::vector <appmap> (); std::vector <appmap> *appItems = new std::vector <appmap> ();
System::Collections::Generic::Dictionary <String ^, Delegate ^> ^jsFunctionHandlers; System::Collections::Generic::Dictionary <String ^, Delegate ^> ^jsFunctionHandlers;
public: public:
AppWindow () AppWindow ()
{ {
BOOL transitionsEnabled = FALSE; this->Visible = false;
HRESULT hr = DwmSetWindowAttribute ( this->DoubleBuffered = true;
reinterpret_cast <HWND> (this->Handle.ToPointer ()),
DWMWA_TRANSITIONS_FORCEDISABLED,
&transitionsEnabled,
sizeof (transitionsEnabled)
);
DWMNCRENDERINGPOLICY dwmplc = DWMNCRP_ENABLED;
hr = DwmSetWindowAttribute (
reinterpret_cast <HWND> (this->Handle.ToPointer ()),
DWMWA_NCRENDERING_POLICY,
&dwmplc,
sizeof (dwmplc)
);
MARGINS margins = {-1, -1, -1, -1};
hr = DwmExtendFrameIntoClientArea (
reinterpret_cast <HWND> (this->Handle.ToPointer ()),
&margins
);
jsFunctionHandlers = gcnew System::Collections::Generic::Dictionary <String ^, Delegate ^> (); jsFunctionHandlers = gcnew System::Collections::Generic::Dictionary <String ^, Delegate ^> ();
this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None; this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::None;
this->ShowInTaskbar = false; this->ShowInTaskbar = false;
this->TopMost = true; this->TopMost = true;
this->Size = System::Drawing::Size (392, 494); this->Size = System::Drawing::Size (392 * dDpi, 494 * dDpi);
if (IsWindows10AndLater ()) this->MinimumSize = System::Drawing::Size (392, 226); if (IsWindows10AndLater ()) this->MinimumSize = System::Drawing::Size (392 * dDpi, 226 * dDpi);
else this->MinimumSize = System::Drawing::Size (392, 129); else this->MinimumSize = System::Drawing::Size (392 * dDpi, 129 * dDpi);
if (IsWindows10AndLater ()) this->MaximumSize = System::Drawing::Size (392, 522); if (IsWindows10AndLater ()) this->MaximumSize = System::Drawing::Size (392 * dDpi, 522 * dDpi);
else this->MaximumSize = System::Drawing::Size (368, 394); else this->MaximumSize = System::Drawing::Size (368 * dDpi, 394 * dDpi);
this->Text = rcString (APPLIST_WINTITLE); this->Text = rcString (APPLIST_WINTITLE);
webUI = gcnew WebBrowser (); webUI = gcnew System::Windows::Forms::WebBrowser ();
webUI->Dock = DockStyle::Fill; webUI->Dock = DockStyle::Fill;
webUI->Visible = false;
this->Controls->Add (webUI); this->Controls->Add (webUI);
String ^rootDir = System::IO::Path::GetDirectoryName (System::Windows::Forms::Application::ExecutablePath); String ^rootDir = System::IO::Path::GetDirectoryName (System::Windows::Forms::Application::ExecutablePath);
String ^htmlFilePath = System::IO::Path::Combine (rootDir, "HTML\\Libs\\AppList.html"); String ^htmlFilePath = System::IO::Path::Combine (rootDir, "HTML\\Libs\\AppList.html");
@@ -386,6 +371,7 @@ public ref class AppWindow: public Form
} }
void OnDocumentCompleted (Object ^sender, WebBrowserDocumentCompletedEventArgs ^e) void OnDocumentCompleted (Object ^sender, WebBrowserDocumentCompletedEventArgs ^e)
{ {
this->CallJSFunction ("SetHighDpiMode", gcnew array <Object ^> { 2 });
CallJSFunction ("SetText", gcnew array <Object ^> { CallJSFunction ("SetText", gcnew array <Object ^> {
"span-title", "span-title",
rcString (APPLIST_TITLE) rcString (APPLIST_TITLE)
@@ -396,8 +382,10 @@ public ref class AppWindow: public Form
}); });
Thread ^thread = gcnew Thread (gcnew ThreadStart (this, &AppWindow::InvokeRefreshAppItems)); Thread ^thread = gcnew Thread (gcnew ThreadStart (this, &AppWindow::InvokeRefreshAppItems));
thread->Start (); thread->Start ();
webUI->Visible = true; // **加载完成后显示 webUI**
this->Visible = true;
} }
void SendAppData (std::vector<appmap> apps) void SendAppData (std::vector <appmap> apps)
{ {
if (appItems) delete appItems; if (appItems) delete appItems;
appItems = nullptr; appItems = nullptr;
@@ -410,9 +398,21 @@ public ref class AppWindow: public Form
} }
void eventLaunchApp (String ^appModelUserId) void eventLaunchApp (String ^appModelUserId)
{ {
taskLaunchApp (appModelUserId);
}
void taskLaunchApp (Object ^parameter)
{
String^ aMUId = safe_cast <String ^> (parameter);
DWORD dwPId = 0; DWORD dwPId = 0;
LaunchApp ((marshal_as <std::wstring> (appModelUserId)).c_str (), &dwPId); LaunchApp ((marshal_as <std::wstring> (aMUId)).c_str (), &dwPId);
this->Close (); if (this->InvokeRequired)
{
if (this->IsHandleCreated) this->Invoke (gcnew Action (this, &AppWindow::Close));
}
else
{
if (this->IsHandleCreated) this->Close ();
}
} }
void eventCancelWindow () void eventCancelWindow ()
{ {
@@ -459,9 +459,9 @@ public ref class AppWindow: public Form
{ {
CallJSFunction ("ClearListItems", gcnew array <Object ^> { }); CallJSFunction ("ClearListItems", gcnew array <Object ^> { });
bool isWin10 = IsWindows10AndLater (); bool isWin10 = IsWindows10AndLater ();
size_t height = ((appItems->size ()) * (isWin10 ? 50 : 60)) + (isWin10 ? 206 : 120); size_t height = ((appItems->size ()) * (isWin10 ? 50 : 60) * dDpi) + (isWin10 ? 206 : 120) * dDpi;
if (height < (isWin10 ? 522 : 394)) this->Height = height; if (height < (isWin10 ? 522 : 394) * dDpi) this->Height = height;
else this->Height = 522; else this->Height = 522 * dDpi;
this->Left = (GetScreenWidth () - this->Width) / 2; this->Left = (GetScreenWidth () - this->Width) / 2;
this->Top = (GetScreenHeight () - this->Height) / 2; this->Top = (GetScreenHeight () - this->Height) / 2;
for (auto it : *appItems) for (auto it : *appItems)
@@ -476,30 +476,44 @@ public ref class AppWindow: public Form
}); });
} }
} }
protected:
virtual void OnHandleCreated (EventArgs^ e) override
{
Form::OnHandleCreated (e);
if (Environment::OSVersion->Version->Major >= 6)
{
MARGINS margins = {0, 0, 0, 0};
HRESULT hr = DwmExtendFrameIntoClientArea ((HWND)this->Handle.ToPointer (), &margins);
}
}
}; };
public ref class MainWnd: public Form public ref class MainWnd: public Form
{ {
private: private:
WebBrowser ^webUI; System::Windows::Forms::WebBrowser ^webUI;
int page; int page;
System::Collections::Generic::Dictionary <String ^, Delegate ^> ^jsFunctionHandlers; System::Collections::Generic::Dictionary <String ^, Delegate ^> ^jsFunctionHandlers;
System::Windows::Forms::Timer^ fadeTimer;
public: public:
MainWnd (): page (-1) MainWnd (): page (-1)
{ {
jsFunctionHandlers = gcnew System::Collections::Generic::Dictionary <String ^, Delegate ^> (); jsFunctionHandlers = gcnew System::Collections::Generic::Dictionary <String ^, Delegate ^> ();
this->Opacity = 0.0;
initWnd (); initWnd ();
} }
private: private:
void initWnd () void initWnd ()
{ {
this->Visible = false; this->Visible = false;
this->webUI = gcnew WebBrowser (); this->DoubleBuffered = true;
this->BackColor = System::Drawing::Color::FromArgb (0, 120, 215);
SetWebBrowserEmulation ();
this->webUI = gcnew System::Windows::Forms::WebBrowser ();
this->webUI->BackColor = this->BackColor;
this->SuspendLayout (); this->SuspendLayout ();
this->webUI->Dock = DockStyle::Fill; this->webUI->Dock = DockStyle::Fill;
this->webUI->DocumentCompleted += gcnew WebBrowserDocumentCompletedEventHandler (this, &MainWnd::eventOnDocumentCompleted);
this->webUI->IsWebBrowserContextMenuEnabled = false; this->webUI->IsWebBrowserContextMenuEnabled = false;
this->webUI->PreviewKeyDown += gcnew System::Windows::Forms::PreviewKeyDownEventHandler (this, &MainWnd::eventOnPreviewKeyDown_WebBrowser);
this->Controls->Add (this->webUI); this->Controls->Add (this->webUI);
HICON tempIco = LoadRCIcon (ICON_TASKBAR); HICON tempIco = LoadRCIcon (ICON_TASKBAR);
if (tempIco) if (tempIco)
@@ -523,10 +537,10 @@ public ref class MainWnd: public Form
} }
else else
{ {
wid = m_initConfig.readUIntValue (L"Settings", L"SavePosWidth", wid = m_initConfig.readUIntValue (L"Settings", L"PosWidth",
(unsigned)_wtol (GetRCString_cpp (INITWIDTH).c_str ()) (unsigned)_wtol (GetRCString_cpp (INITWIDTH).c_str ())
); );
hei = m_initConfig.readUIntValue (L"Settings", L"SavePosHeight", hei = m_initConfig.readUIntValue (L"Settings", L"PosHeight",
(unsigned)_wtol (GetRCString_cpp (INITHEIGHT).c_str ()) (unsigned)_wtol (GetRCString_cpp (INITHEIGHT).c_str ())
); );
} }
@@ -535,21 +549,22 @@ public ref class MainWnd: public Form
m_initConfig.readUIntValue (L"Settings", L"MinPosHeight", (unsigned)_wtol (GetRCString_cpp (LIMITHEIGHT).c_str ())) m_initConfig.readUIntValue (L"Settings", L"MinPosHeight", (unsigned)_wtol (GetRCString_cpp (LIMITHEIGHT).c_str ()))
); );
this->WindowState = (System::Windows::Forms::FormWindowState)m_initConfig.readIntValue (L"Settings", L"WindowPos", (int)System::Windows::Forms::FormWindowState::Normal); this->WindowState = (System::Windows::Forms::FormWindowState)m_initConfig.readIntValue (L"Settings", L"WindowPos", (int)System::Windows::Forms::FormWindowState::Normal);
this->ClientSize = System::Drawing::Size (wid, hei); this->ClientSize = System::Drawing::Size (wid * dDpi, hei * dDpi);
this->Text = GetRCString (WIN_TITLE); this->Text = GetRCString (WIN_TITLE);
this->ResumeLayout (false);
webUI->ObjectForScripting = this;
this->webUI->DocumentCompleted += gcnew WebBrowserDocumentCompletedEventHandler (this, &MainWnd::eventOnDocumentCompleted);
this->webUI->PreviewKeyDown += gcnew System::Windows::Forms::PreviewKeyDownEventHandler (this, &MainWnd::eventOnPreviewKeyDown_WebBrowser);
this->Resize += gcnew System::EventHandler (this, &MainWnd::eventOnResize);
this->Load += gcnew EventHandler (this, &MainWnd::eventOnCreate); this->Load += gcnew EventHandler (this, &MainWnd::eventOnCreate);
this->ResizeEnd += gcnew EventHandler (this, &MainWnd::eventOnResizeEnd); this->ResizeEnd += gcnew EventHandler (this, &MainWnd::eventOnResizeEnd);
this->ResumeLayout (false);
this->Resize += gcnew System::EventHandler (this, &MainWnd::eventOnResize);
} }
void eventOnCreate (System::Object ^sender, System::EventArgs ^e) void eventOnCreate (System::Object ^sender, System::EventArgs ^e)
{ {
SetWebBrowserEmulation ();
String ^rootDir = System::IO::Path::GetDirectoryName (System::Windows::Forms::Application::ExecutablePath); String ^rootDir = System::IO::Path::GetDirectoryName (System::Windows::Forms::Application::ExecutablePath);
String ^htmlFilePath = System::IO::Path::Combine (rootDir, "HTML\\Index.html"); String ^htmlFilePath = System::IO::Path::Combine (rootDir, "HTML\\Index.html");
if (IsIeVersion10 ()) htmlFilePath = System::IO::Path::Combine (rootDir, "HTML\\IndexIE10.html"); // IE10 (Win8) 特供 if (IsIeVersion10 ()) htmlFilePath = System::IO::Path::Combine (rootDir, "HTML\\IndexIE10.html"); // IE10 (Win8) 特供
webUI->Navigate (htmlFilePath); webUI->Navigate (htmlFilePath);
webUI->ObjectForScripting = this;
} }
void eventOnPreviewKeyDown_WebBrowser (System::Object ^sender, System::Windows::Forms::PreviewKeyDownEventArgs ^e) void eventOnPreviewKeyDown_WebBrowser (System::Object ^sender, System::Windows::Forms::PreviewKeyDownEventArgs ^e)
{ {
@@ -560,9 +575,25 @@ public ref class MainWnd: public Form
{ {
if (e->Url->ToString () == webUI->Url->ToString ()) if (e->Url->ToString () == webUI->Url->ToString ())
{ {
eventOnPageLoad (); this->CallJSFunction ("SetHighDpiMode", gcnew array <Object ^> { 2 });
this->CallJSFunction ("SetPageZoom", gcnew array <Object ^> { dDpi });
this->Visible = true;
fadeTimer = gcnew System::Windows::Forms::Timer ();
fadeTimer->Interval = 5;
fadeTimer->Tick += gcnew EventHandler (this, &MainWnd::fadeTimer_Tick);
fadeTimer->Start ();
this->setLaunchWhenReadyJS (m_initConfig.readBoolValue (L"Settings", L"LaunchWhenReady", true));
Thread ^thread = gcnew Thread (gcnew ThreadStart (this, &MainWnd::taskReadFile));
thread->Start ();
Thread ^thread2 = gcnew Thread (gcnew ThreadStart (this, &MainWnd::taskCountDarkMode));
thread2->Start ();
} }
} }
void fadeTimer_Tick (Object^ sender, EventArgs^ e)
{
if (this->Opacity < 1.0) this->Opacity += 0.2;
else fadeTimer->Stop ();
}
void eventOnResizeEnd (Object ^sender, EventArgs ^e) void eventOnResizeEnd (Object ^sender, EventArgs ^e)
{ {
if (this->WindowState == FormWindowState::Maximized) if (this->WindowState == FormWindowState::Maximized)
@@ -574,7 +605,7 @@ public ref class MainWnd: public Form
this->changeMaxDisplayPicJS (false); this->changeMaxDisplayPicJS (false);
} }
} }
void eventOnResize (Object ^sender, EventArgs ^e) void adjustWhenResize ()
{ {
if (this->WindowState == FormWindowState::Maximized) if (this->WindowState == FormWindowState::Maximized)
{ {
@@ -587,22 +618,44 @@ public ref class MainWnd: public Form
this->changeMaxDisplayPicJS (false); this->changeMaxDisplayPicJS (false);
if (m_initConfig.readBoolValue (L"Settings", L"SavePosBeforeClosing")) if (m_initConfig.readBoolValue (L"Settings", L"SavePosBeforeClosing"))
{ {
m_initConfig.writeUIntValue (L"Settings", L"SavePosWidth", this->Width); System::Drawing::Size ^client = this->ClientSize;
m_initConfig.writeUIntValue (L"Settings", L"SavePosHeight", this->Height); if (dDpi == 1)
{
m_initConfig.writeUIntValue (L"Settings", L"SavePosWidth", client->Width);
m_initConfig.writeUIntValue (L"Settings", L"SavePosHeight", client->Height);
}
else
{
m_initConfig.writeUIntValue (L"Settings", L"SavePosWidth", client->Width / dDpi);
m_initConfig.writeUIntValue (L"Settings", L"SavePosHeight", client->Height / dDpi);
}
}
}
if (this->webUI->IsHandleCreated)
{
UINT resID = 0;
switch (page)
{
case 2: resID = PAGE_1_TITLE; break;
case 3: resID = PAGE_2_TITLE; break;
case 4: resID = PAGE_4_TITLE; break;
case 5: resID = PAGE_5_TITLE; break;
}
if (resID)
{
std::wstring title = m_pkgInfo.getPropertyName ();
std::wstring temp = StrPrintFormatW (GetRCString_cpp (resID).c_str (), L"  ");
std::wstring temp1 = temp + title;
size_t reduce = getTextOmitAdviceJS (gcnew String ("caption-title"), gcnew String (temp1.c_str ()), (size_t)2);
std::wstring sub = title.substr (0, title.length () - reduce) + (reduce > 3 ? L"..." : L"");
setTextJS ("caption-title", gcnew String (StrPrintFormatW (GetRCString_cpp (resID).c_str (), sub.c_str ()).c_str ()));
// this->CallJSFunction ("adjustTextareaHeight", gcnew array <Object ^> {});
} }
} }
} }
void eventOnPageLoad () void eventOnResize (Object ^sender, EventArgs ^e)
{ {
this->Visible = true; this->adjustWhenResize ();
this->setLaunchWhenReadyJS (m_initConfig.readBoolValue (L"Settings", L"LaunchWhenReady", true));
#ifdef _DEBUG
if (IsIeVersion10 ()) hideFrameJS (false);
#endif
Thread ^thread = gcnew Thread (gcnew ThreadStart (this, &MainWnd::taskReadFile));
thread->Start ();
Thread ^thread2 = gcnew Thread (gcnew ThreadStart (this, &MainWnd::taskCountDarkMode));
thread2->Start ();
} }
void eventOnPress_button1 () void eventOnPress_button1 ()
{ {
@@ -884,6 +937,21 @@ public ref class MainWnd: public Form
setProgressTextJS (content); setProgressTextJS (content);
} }
} }
void adjustTextareaHeightJS ()
{
this->CallJSFunction ("adjustTextareaHeight", gcnew array <Object ^> {});
}
void invokeAdjustTextareaHeight ()
{
if (this->InvokeRequired)
{
this->Invoke (gcnew Action (this, &MainWnd::adjustTextareaHeightJS));
}
else
{
adjustTextareaHeightJS ();
}
}
void setPage (int serial) void setPage (int serial)
{ {
switch (serial) switch (serial)
@@ -898,8 +966,10 @@ public ref class MainWnd: public Form
break; break;
case 2: case 2:
{ {
std::wstring title = m_pkgInfo.getPropertyName (), titleF = StrPrintFormatW (GetRCString_cpp (PAGE_1_TITLE).c_str (), title.c_str ()); std::wstring title = m_pkgInfo.getPropertyName ();
size_t reduce = getTextOmitAdviceJS (gcnew String ("caption-title"), gcnew String (titleF.c_str ()), (size_t)2); std::wstring temp = StrPrintFormatW (GetRCString_cpp (PAGE_1_TITLE).c_str (), L"  ");
std::wstring temp1 = temp + title;
size_t reduce = getTextOmitAdviceJS (gcnew String ("caption-title"), gcnew String (temp1.c_str ()), (size_t)2);
std::wstring sub = title.substr (0, title.length () - reduce) + (reduce > 3 ? L"..." : L""); std::wstring sub = title.substr (0, title.length () - reduce) + (reduce > 3 ? L"..." : L"");
setTextJS ("caption-title", gcnew String (StrPrintFormatW (GetRCString_cpp (PAGE_1_TITLE).c_str (), sub.c_str ()).c_str ())); setTextJS ("caption-title", gcnew String (StrPrintFormatW (GetRCString_cpp (PAGE_1_TITLE).c_str (), sub.c_str ()).c_str ()));
} }
@@ -976,16 +1046,20 @@ public ref class MainWnd: public Form
case 3: case 3:
{ {
invokeSetProgressText (rcString (PAGE_2_LOADING)); invokeSetProgressText (rcString (PAGE_2_LOADING));
std::wstring title = m_pkgInfo.getPropertyName (), titleF = StrPrintFormatW (GetRCString_cpp (PAGE_2_TITLE).c_str (), title.c_str ()); std::wstring title = m_pkgInfo.getPropertyName ();
size_t reduce = getTextOmitAdviceJS (gcnew String ("caption-title"), gcnew String (titleF.c_str ()), (size_t)2); std::wstring temp = StrPrintFormatW (GetRCString_cpp (PAGE_2_TITLE).c_str (), L"  ");
std::wstring temp1 = temp + title;
size_t reduce = getTextOmitAdviceJS (gcnew String ("caption-title"), gcnew String (temp1.c_str ()), (size_t)2);
std::wstring sub = title.substr (0, title.length () - reduce) + (reduce > 3 ? L"..." : L""); std::wstring sub = title.substr (0, title.length () - reduce) + (reduce > 3 ? L"..." : L"");
setTextJS ("caption-title", gcnew String (StrPrintFormatW (GetRCString_cpp (PAGE_2_TITLE).c_str (), sub.c_str ()).c_str ())); setTextJS ("caption-title", gcnew String (StrPrintFormatW (GetRCString_cpp (PAGE_2_TITLE).c_str (), sub.c_str ()).c_str ()));
} }
break; break;
case 4: case 4:
{ {
std::wstring title = m_pkgInfo.getPropertyName (), titleF = StrPrintFormatW (GetRCString_cpp (PAGE_4_TITLE).c_str (), title.c_str ()); std::wstring title = m_pkgInfo.getPropertyName ();
size_t reduce = getTextOmitAdviceJS (gcnew String ("caption-title"), gcnew String (titleF.c_str ()), (size_t)2); std::wstring temp = StrPrintFormatW (GetRCString_cpp (PAGE_4_TITLE).c_str (), L"  ");
std::wstring temp1 = temp + title;
size_t reduce = getTextOmitAdviceJS (gcnew String ("caption-title"), gcnew String (temp1.c_str ()), (size_t)2);
std::wstring sub = title.substr (0, title.length () - reduce) + (reduce > 3 ? L"..." : L""); std::wstring sub = title.substr (0, title.length () - reduce) + (reduce > 3 ? L"..." : L"");
setTextJS ("caption-title", gcnew String (StrPrintFormatW (GetRCString_cpp (PAGE_4_TITLE).c_str (), sub.c_str ()).c_str ())); setTextJS ("caption-title", gcnew String (StrPrintFormatW (GetRCString_cpp (PAGE_4_TITLE).c_str (), sub.c_str ()).c_str ()));
} }
@@ -1005,8 +1079,10 @@ public ref class MainWnd: public Form
break; break;
case 5: case 5:
{ {
std::wstring title = m_pkgInfo.getPropertyName (), titleF = StrPrintFormatW (GetRCString_cpp (PAGE_5_TITLE).c_str (), title.c_str ()); std::wstring title = m_pkgInfo.getPropertyName ();
size_t reduce = getTextOmitAdviceJS (gcnew String ("caption-title"), gcnew String (titleF.c_str ()), (size_t)2); std::wstring temp = StrPrintFormatW (GetRCString_cpp (PAGE_5_TITLE).c_str (), L"  ");
std::wstring temp1 = temp + title;
size_t reduce = getTextOmitAdviceJS (gcnew String ("caption-title"), gcnew String (temp1.c_str ()), (size_t)2);
std::wstring sub = title.substr (0, title.length () - reduce) + (reduce > 3 ? L"..." : L""); std::wstring sub = title.substr (0, title.length () - reduce) + (reduce > 3 ? L"..." : L"");
setTextJS ("caption-title", gcnew String (StrPrintFormatW (GetRCString_cpp (PAGE_5_TITLE).c_str (), sub.c_str ()).c_str ())); setTextJS ("caption-title", gcnew String (StrPrintFormatW (GetRCString_cpp (PAGE_5_TITLE).c_str (), sub.c_str ()).c_str ()));
if (GetLastErrorDetailTextLength ()) setTextJS ("caption-more-info", gcnew String (GetLastErrorDetailText ())); if (GetLastErrorDetailTextLength ()) setTextJS ("caption-more-info", gcnew String (GetLastErrorDetailText ()));
@@ -1041,6 +1117,7 @@ public ref class MainWnd: public Form
setPicBoxVisibilityJS (false); setPicBoxVisibilityJS (false);
} }
page = serial; page = serial;
this->adjustWhenResize ();
} }
void invokeSetPage (int page) void invokeSetPage (int page)
{ {
@@ -1169,14 +1246,28 @@ public ref class MainWnd: public Form
if (m_silentMode) if (m_silentMode)
{ {
// 在此版本中,在静默模式下打开无效的包后会自动关闭窗口结束程序。 // 在此版本中,在静默模式下打开无效的包后会自动关闭窗口结束程序。
this->Close (); while (!this->IsHandleCreated) {};
if (this->IsHandleCreated)
{
if (this->InvokeRequired)
{
this->Invoke (gcnew Action (this, &MainWnd::Close));
}
else
{
this->Close ();
}
}
} }
else else
{ {
invokeSetPage (1); invokeSetPage (1);
} }
} }
this->invokeSetDarkMode (IsAppInDarkMode ()); if (this->IsHandleCreated)
{
this->invokeSetDarkMode (IsAppInDarkMode ());
}
EmptyWorkingSet ((HANDLE)-1); EmptyWorkingSet ((HANDLE)-1);
} }
void taskInstallPackage () void taskInstallPackage ()
@@ -1196,10 +1287,12 @@ public ref class MainWnd: public Form
invokeSetProgressText (rcString (PAGE_2_INSTALL)); invokeSetProgressText (rcString (PAGE_2_INSTALL));
InstallStatus status = AddPackageFromPath (pkgPath.c_str (), &ProgressCallback); InstallStatus status = AddPackageFromPath (pkgPath.c_str (), &ProgressCallback);
// MessageBeep (MB_OK); // MessageBeep (MB_OK);
std::wstring title (L"");
if (status == InstallStatus::Success) if (status == InstallStatus::Success)
{ {
invokeSetPage (4); invokeSetPage (4);
if (m_pkgInfo.applications.size () == 1 && !m_silentMode) this->eventOnPress_button1 (); // 用于启用 APP title = StrPrintFormatW (GetRCString_cpp (PAGE_4_TITLE).c_str (), m_pkgInfo.getPropertyName ().c_str ());
if (m_pkgInfo.applications.size () == 1 && !m_silentMode && this->invokeGetLaunchWhenReady ()) this->eventOnPress_button1 (); // 用于启用 APP
Thread ^closeThread = gcnew Thread (gcnew ThreadStart (this, &MainWnd::taskCountCancel)); Thread ^closeThread = gcnew Thread (gcnew ThreadStart (this, &MainWnd::taskCountCancel));
closeThread->IsBackground = true; closeThread->IsBackground = true;
closeThread->Start (); closeThread->Start ();
@@ -1207,6 +1300,7 @@ public ref class MainWnd: public Form
else else
{ {
invokeSetPage (5); invokeSetPage (5);
title = StrPrintFormatW (GetRCString_cpp (PAGE_5_TITLE).c_str (), m_pkgInfo.getPropertyName ().c_str ());
if (m_silentMode) if (m_silentMode)
{ {
Thread ^closeThread = gcnew Thread (gcnew ThreadStart (this, &MainWnd::taskCountCancel)); Thread ^closeThread = gcnew Thread (gcnew ThreadStart (this, &MainWnd::taskCountCancel));
@@ -1215,7 +1309,6 @@ public ref class MainWnd: public Form
} }
} }
this->invokeClearTaskbarProgress (); this->invokeClearTaskbarProgress ();
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 (), &ToastPressCallback, m_pkgInfo.getPropertyLogoIStream ()); bool res = CreateToastNotification (m_idenName, title.c_str (), text.c_str (), &ToastPressCallback, m_pkgInfo.getPropertyLogoIStream ());
@@ -1325,7 +1418,8 @@ std::vector <CMDARGUMENT> cmdargs =
{{L"", L"/", L"-"}, {L"CREATESHORTCUT", L"SHORTCUT", L"CREATELNK"}, {}, 8}, {{L"", L"/", L"-"}, {L"CREATESHORTCUT", L"SHORTCUT", L"CREATELNK"}, {}, 8},
{{L"", L"/", L"-"}, {L"DELETESHORTCUT", L"DELSHORTCUT", L"DELETELNK"}, {}, 9}, {{L"", L"/", L"-"}, {L"DELETESHORTCUT", L"DELSHORTCUT", L"DELETELNK"}, {}, 9},
{{L"", L"/", L"-"}, {L"DEVTOOL", L"DEVTOOLS", L"DEVMODE", L"DEVELOP"}, {}, 10}, {{L"", L"/", L"-"}, {L"DEVTOOL", L"DEVTOOLS", L"DEVMODE", L"DEVELOP"}, {}, 10},
{{L"", L"/", L"-"}, {L"USEEPROGRAM", L"EPROGRAM", L"ESUPPORT", L"USEE"}, {}, 11} {{L"", L"/", L"-"}, {L"USEEPROGRAM", L"EPROGRAM", L"ESUPPORT", L"USEE"}, {}, 11},
{{L"", L"/", L"-"}, {L"CONSOLE", L"CONSOLECLIENT"}, {}, 12},
}; };
// 编号为大于 0 的数,失败返回非正数 // 编号为大于 0 的数,失败返回非正数
@@ -1397,9 +1491,9 @@ bool ReadCommand (int argc, LPWSTR *argv)
{ {
std::vector <std::wstring> vecObjSwFiles; std::vector <std::wstring> vecObjSwFiles;
bool bWin32Wnd = false, bSilent = false, bVerySilent = false, bool bWin32Wnd = false, bSilent = false, bVerySilent = false,
bUseConsole = false, bUseNewFrame = false, bDisplayHelp = false, bUseCmd = false, bUseNewFrame = false, bDisplayHelp = false,
bCreateLnk = false, bDestroyLnk = false, bDevTool = false, bCreateLnk = false, bDestroyLnk = false, bDevTool = false,
bUseEProgream = false; bUseEProgream = false, bConsole = false;
for (size_t cnt = 0; cnt < (size_t)argc; cnt ++) for (size_t cnt = 0; cnt < (size_t)argc; cnt ++)
{ {
int res = GetCmdArgSerial (argv [cnt]); int res = GetCmdArgSerial (argv [cnt]);
@@ -1410,7 +1504,7 @@ bool ReadCommand (int argc, LPWSTR *argv)
case 1: bUseNewFrame = false; break; case 1: bUseNewFrame = false; break;
case 2: bSilent = true; break; case 2: bSilent = true; break;
case 3: bVerySilent = true; break; case 3: bVerySilent = true; break;
case 4: bUseConsole = true; break; case 4: bUseCmd = true; break;
case 5: bDisplayHelp = true; break; case 5: bDisplayHelp = true; break;
case 6: bUseNewFrame = true; break; case 6: bUseNewFrame = true; break;
case 7: bWin32Wnd = true; break; case 7: bWin32Wnd = true; break;
@@ -1418,6 +1512,7 @@ bool ReadCommand (int argc, LPWSTR *argv)
case 9: bDestroyLnk = true; break; case 9: bDestroyLnk = true; break;
case 10: bDevTool = true; break; case 10: bDevTool = true; break;
case 11: bUseEProgream = true; break; case 11: bUseEProgream = true; break;
case 12: bConsole = true; break;
} }
} }
else else
@@ -1433,9 +1528,14 @@ bool ReadCommand (int argc, LPWSTR *argv)
MessageBox::Show ( MessageBox::Show (
rcString (CLHELP_1) + rcString (CLHELP_1) +
rcString (CLHELP_2) + rcString (CLHELP_2) +
rcString (CLHELP_3) +
rcString (CLHELP_4) + rcString (CLHELP_4) +
rcString (CLHELP_5) + rcString (CLHELP_5) +
rcString (CLHELP_7) rcString (CLHELP_6) +
rcString (CLHELP_7) +
rcString (CLHELP_8) +
rcString (CLHELP_9) +
rcString (CLHELP_10)
); );
return false; return false;
} }
@@ -1459,6 +1559,12 @@ bool ReadCommand (int argc, LPWSTR *argv)
_itow (WIN_TITLE, resIdStr, 10); _itow (WIN_TITLE, resIdStr, 10);
desktop.writeUIntValue (L".ShellClassInfo", L"ConfirmFileOp", 0); desktop.writeUIntValue (L".ShellClassInfo", L"ConfirmFileOp", 0);
desktop.writeStringValue (L"LocalizedFileNames", L"App Installer.lnk", std::wstring (L"@") + path + L",-" + resIdStr); desktop.writeStringValue (L"LocalizedFileNames", L"App Installer.lnk", std::wstring (L"@") + path + L",-" + resIdStr);
_itow (SHORTCUT_SETTINGS, resIdStr, 10);
desktop.writeStringValue (L"LocalizedFileNames", L"Settings.lnk", std::wstring (L"@") + path + L",-" + resIdStr);
_itow (SHORTCUT_UNINSTALL, resIdStr, 10);
desktop.writeStringValue (L"LocalizedFileNames", L"Uninstaller.lnk", std::wstring (L"@") + path + L",-" + resIdStr);
_itow (SHORTCUT_UPDATE, resIdStr, 10);
desktop.writeStringValue (L"LocalizedFileNames", L"Update.lnk", std::wstring (L"@") + path + L",-" + resIdStr);
DWORD attrs = GetFileAttributesW (desktopIni); DWORD attrs = GetFileAttributesW (desktopIni);
SetFileAttributesW (desktopIni, attrs | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM); SetFileAttributesW (desktopIni, attrs | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM);
DWORD folderAttrs = GetFileAttributesW (expandedPath); DWORD folderAttrs = GetFileAttributesW (expandedPath);
@@ -1501,7 +1607,7 @@ bool ReadCommand (int argc, LPWSTR *argv)
else args += L"/DISABLEFRAME "; else args += L"/DISABLEFRAME ";
if (bSilent) args += L"/SILENT "; if (bSilent) args += L"/SILENT ";
if (bVerySilent) args += L"/VERYSILENT "; if (bVerySilent) args += L"/VERYSILENT ";
if (bUseConsole) args += L"/NOGUI "; if (bUseCmd) args += L"/NOGUI ";
if (bDisplayHelp) args += L"/? "; if (bDisplayHelp) args += L"/? ";
std::wstring cmdline = L"\"" + exepath + L"\" " + args; std::wstring cmdline = L"\"" + exepath + L"\" " + args;
{ {
@@ -1526,7 +1632,7 @@ bool ReadCommand (int argc, LPWSTR *argv)
else args += L"/DISABLEFRAME "; else args += L"/DISABLEFRAME ";
if (bSilent) args += L"/SILENT "; if (bSilent) args += L"/SILENT ";
if (bVerySilent) args += L"/VERYSILENT "; if (bVerySilent) args += L"/VERYSILENT ";
if (bUseConsole) args += L"/NOGUI "; if (bUseCmd) args += L"/NOGUI ";
if (bDisplayHelp) args += L"/? "; if (bDisplayHelp) args += L"/? ";
std::wstring cmdline = L"\"" + exepath + L"\" " + args; std::wstring cmdline = L"\"" + exepath + L"\" " + args;
{ {
@@ -1541,7 +1647,7 @@ bool ReadCommand (int argc, LPWSTR *argv)
} }
} }
} }
else if (bUseConsole) else if (bUseCmd)
{ {
std::wstring root = EnsureTrailingSlash (GetProgramRootDirectoryW ()); std::wstring root = EnsureTrailingSlash (GetProgramRootDirectoryW ());
std::wstring exepath = root + L"WSAppPkgIns.exe"; std::wstring exepath = root + L"WSAppPkgIns.exe";
@@ -1560,6 +1666,25 @@ bool ReadCommand (int argc, LPWSTR *argv)
} }
} }
} }
else if (bConsole)
{
std::wstring root = EnsureTrailingSlash (GetProgramRootDirectoryW ());
std::wstring exepath = root + L"AppInstallerConsole.exe";
std::wstring args = L"";
args += L"\"" + pkgPath + L"\" ";
std::wstring cmdline = L"\"" + exepath + L"\" " + args;
{
STARTUPINFOW si = {sizeof (STARTUPINFOW)};
PROCESS_INFORMATION pi = {0};
if (CreateProcessW (NULL, (LPWSTR)cmdline.c_str (), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
WaitForSingleObject (pi.hProcess, INFINITE);
CloseHandle (pi.hProcess);
CloseHandle (pi.hThread);
return false;
}
}
}
return true; return true;
} }
else if (vecObjSwFiles.size () <= 0) else if (vecObjSwFiles.size () <= 0)
@@ -1573,7 +1698,7 @@ bool ReadCommand (int argc, LPWSTR *argv)
else args += L"/DISABLEFRAME "; else args += L"/DISABLEFRAME ";
if (bSilent) args += L"/SILENT "; if (bSilent) args += L"/SILENT ";
if (bVerySilent) args += L"/VERYSILENT "; if (bVerySilent) args += L"/VERYSILENT ";
if (bUseConsole) args += L"/NOGUI "; if (bUseCmd) args += L"/NOGUI ";
if (bDisplayHelp) args += L"/? "; if (bDisplayHelp) args += L"/? ";
std::wstring cmdline = L"\"" + exepath + L"\" " + args; std::wstring cmdline = L"\"" + exepath + L"\" " + args;
{ {
@@ -1597,7 +1722,7 @@ bool ReadCommand (int argc, LPWSTR *argv)
else args += L"/DISABLEFRAME "; else args += L"/DISABLEFRAME ";
if (bSilent) args += L"/SILENT "; if (bSilent) args += L"/SILENT ";
if (bVerySilent) args += L"/VERYSILENT "; if (bVerySilent) args += L"/VERYSILENT ";
if (bUseConsole) args += L"/NOGUI "; if (bUseCmd) args += L"/NOGUI ";
if (bDisplayHelp) args += L"/? "; if (bDisplayHelp) args += L"/? ";
if (bDevTool) args += L"/DEVTOOL "; if (bDevTool) args += L"/DEVTOOL ";
std::wstring cmdline = L"\"" + exepath + L"\" " + args; std::wstring cmdline = L"\"" + exepath + L"\" " + args;
@@ -1613,34 +1738,59 @@ bool ReadCommand (int argc, LPWSTR *argv)
} }
} }
} }
else if (bUseCmd || bConsole) return false;
else return true; else return true;
} }
else if (vecObjSwFiles.size () > 1) // 面对多个文件 else if (vecObjSwFiles.size () > 1) // 面对多个文件
{ {
for (auto it : vecObjSwFiles) if (bConsole)
{ {
wchar_t path [MAX_PATH] = {0}; std::wstring root = EnsureTrailingSlash (GetProgramRootDirectoryW ());
if (GetModuleFileNameW (NULL, path, MAX_PATH)) std::wstring exepath = root + L"AppInstallerConsole.exe";
{ std::wstring args = L"";
std::wstring args = L""; for (auto it : vecObjSwFiles)
args += L"\"" + it + L"\" ";
if (bUseNewFrame) args += L"/ENABLEFRAME ";
else args += L"/DISABLEFRAME ";
if (bSilent) args += L"/SILENT ";
if (bVerySilent) args += L"/VERYSILENT ";
if (bUseConsole) args += L"/NOGUI ";
if (bDisplayHelp) args += L"/? ";
if (bWin32Wnd) args += L"WIN32WINDOW ";
if (bUseEProgream) args += L"/USEEPROGRAM ";
std::wstring cmdline = L"\"" + std::wstring (path) + L"\" " + args;
{ {
STARTUPINFOW si = {sizeof (STARTUPINFOW)}; args += L" \"" + it + L"\"";
PROCESS_INFORMATION pi = {0}; }
if (CreateProcessW (NULL, (LPWSTR)cmdline.c_str (), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) std::wstring cmdline = L"\"" + exepath + L"\"" + args;
{
STARTUPINFOW si = {sizeof (STARTUPINFOW)};
PROCESS_INFORMATION pi = {0};
if (CreateProcessW (NULL, (LPWSTR)cmdline.c_str (), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
WaitForSingleObject (pi.hProcess, INFINITE);
CloseHandle (pi.hProcess);
CloseHandle (pi.hThread);
}
}
}
else
{
for (auto it : vecObjSwFiles)
{
wchar_t path [MAX_PATH] = {0};
if (GetModuleFileNameW (NULL, path, MAX_PATH))
{
std::wstring args = L"";
args += L"\"" + it + L"\" ";
if (bUseNewFrame) args += L"/ENABLEFRAME ";
else args += L"/DISABLEFRAME ";
if (bSilent) args += L"/SILENT ";
if (bVerySilent) args += L"/VERYSILENT ";
if (bUseCmd) args += L"/NOGUI ";
if (bDisplayHelp) args += L"/? ";
if (bWin32Wnd) args += L"WIN32WINDOW ";
if (bUseEProgream) args += L"/USEEPROGRAM ";
std::wstring cmdline = L"\"" + std::wstring (path) + L"\" " + args;
{ {
WaitForSingleObject (pi.hProcess, INFINITE); STARTUPINFOW si = {sizeof (STARTUPINFOW)};
CloseHandle (pi.hProcess); PROCESS_INFORMATION pi = {0};
CloseHandle (pi.hThread); if (CreateProcessW (NULL, (LPWSTR)cmdline.c_str (), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
WaitForSingleObject (pi.hProcess, INFINITE);
CloseHandle (pi.hProcess);
CloseHandle (pi.hThread);
}
} }
} }
} }

View File

@@ -1142,6 +1142,9 @@
#define APPLIST_WINTITLE 324 #define APPLIST_WINTITLE 324
#define APPLIST_TITLE 325 #define APPLIST_TITLE 325
#define APPLIST_BUTTON_CANCEL 326 #define APPLIST_BUTTON_CANCEL 326
#define SHORTCUT_SETTINGS 327
#define SHORTCUT_UNINSTALL 328
#define SHORTCUT_UPDATE 329
#define CLHELP_1 330 #define CLHELP_1 330
#define CLHELP_2 331 #define CLHELP_2 331
#define CLHELP_3 332 #define CLHELP_3 332
@@ -1149,6 +1152,9 @@
#define CLHELP_5 334 #define CLHELP_5 334
#define CLHELP_6 335 #define CLHELP_6 335
#define CLHELP_7 336 #define CLHELP_7 336
#define CLHELP_8 337
#define CLHELP_9 338
#define CLHELP_10 339
#define INITWIDTH 400 #define INITWIDTH 400
#define INITHEIGHT 401 #define INITHEIGHT 401
#define LIMITWIDTH 402 #define LIMITWIDTH 402

View File

@@ -115,8 +115,8 @@ IDR_MANIFEST1 RT_MANIFEST "res/manifest.xml"
// //
IDR_VERSION_ZH_CN VERSIONINFO IDR_VERSION_ZH_CN VERSIONINFO
FILEVERSION 1,0,1,7 FILEVERSION 1,0,1,9
PRODUCTVERSION 1,0,1,7 PRODUCTVERSION 1,0,1,9
FILEFLAGSMASK 0x0L FILEFLAGSMASK 0x0L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@@ -133,9 +133,9 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Bruce Winter" VALUE "CompanyName", "Bruce Winter"
VALUE "FileDescription", "应用安装程序" VALUE "FileDescription", "应用安装程序"
VALUE "FileVersion", "1.0.1.7" VALUE "FileVersion", "1.0.1.9"
VALUE "LegalCopyright", "\\xA9Bruce Winter. All rights reserved." VALUE "LegalCopyright", "\\xA9Bruce Winter. All rights reserved."
VALUE "ProductVersion", "1.0.1.7" VALUE "ProductVersion", "1.0.1.9"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
@@ -145,8 +145,8 @@ BEGIN
END END
IDR_VERSION_EN_US VERSIONINFO IDR_VERSION_EN_US VERSIONINFO
FILEVERSION 1,0,1,7 FILEVERSION 1,0,1,9
PRODUCTVERSION 1,0,1,7 PRODUCTVERSION 1,0,1,9
FILEFLAGSMASK 0x0L FILEFLAGSMASK 0x0L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@@ -163,9 +163,9 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Bruce Winter" VALUE "CompanyName", "Bruce Winter"
VALUE "FileDescription", "App Installer" VALUE "FileDescription", "App Installer"
VALUE "FileVersion", "1.0.1.7" VALUE "FileVersion", "1.0.1.9"
VALUE "LegalCopyright", "\\xA9Bruce Winter. All rights reserved." VALUE "LegalCopyright", "\\xA9Bruce Winter. All rights reserved."
VALUE "ProductVersion", "1.0.1.7" VALUE "ProductVersion", "1.0.1.9"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@@ -166,6 +166,46 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Image Include="res\Button\Large\blank.png" />
<Image Include="res\Button\Large\blank_light.png" />
<Image Include="res\Button\Large\blank_press.png" />
<Image Include="res\Button\Large\cancel_window_light.png" />
<Image Include="res\Button\Large\cancel_window_normal.png" />
<Image Include="res\Button\Large\cancel_window_press.png" />
<Image Include="res\Button\Large\max_light.png" />
<Image Include="res\Button\Large\max_normal.png" />
<Image Include="res\Button\Large\max_press.png" />
<Image Include="res\Button\Large\min_light.png" />
<Image Include="res\Button\Large\min_normal.png" />
<Image Include="res\Button\Large\min_press.png" />
<Image Include="res\Button\Large\restore_light.png" />
<Image Include="res\Button\Large\restore_normal.png" />
<Image Include="res\Button\Large\restore_press.png" />
<Image Include="res\Button\Normal\blank.png" />
<Image Include="res\Button\Normal\blank_light.png" />
<Image Include="res\Button\Normal\blank_press.png" />
<Image Include="res\Button\Normal\cancel_back.png" />
<Image Include="res\Button\Normal\cancel_light.png" />
<Image Include="res\Button\Normal\cancel_press.png" />
<Image Include="res\Button\Normal\max_back.png" />
<Image Include="res\Button\Normal\max_light.png" />
<Image Include="res\Button\Normal\max_press.png" />
<Image Include="res\Button\Normal\min_back.png" />
<Image Include="res\Button\Normal\min_light.png" />
<Image Include="res\Button\Normal\min_press.png" />
<Image Include="res\Button\Normal\restore_back.png" />
<Image Include="res\Button\Normal\restore_light.png" />
<Image Include="res\Button\Normal\restore_press.png" />
<Image Include="res\Icons\FileIcon.ico" />
<Image Include="res\Icons\IconColor.ico" />
<Image Include="res\Icons\IconTitleBar.ico" />
<Image Include="res\Icons\IconWhite.ico" />
<Image Include="res\Icons\Main.ico" />
</ItemGroup>
<ItemGroup>
<Xml Include="res\manifest.xml" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@@ -47,4 +47,114 @@
<Filter>源文件</Filter> <Filter>源文件</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Image Include="res\Icons\Main.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Icons\FileIcon.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Icons\IconWhite.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Icons\IconColor.ico">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\blank.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\blank_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\blank_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\min_back.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\min_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\min_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\max_back.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\max_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\max_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\restore_back.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\restore_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\restore_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\cancel_back.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\cancel_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Normal\cancel_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\blank.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\blank_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\blank_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\min_normal.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\min_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\min_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\max_normal.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\max_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\max_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\restore_normal.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\restore_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\restore_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\cancel_window_normal.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\cancel_window_light.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Button\Large\cancel_window_press.png">
<Filter>资源文件</Filter>
</Image>
<Image Include="res\Icons\IconTitleBar.ico">
<Filter>资源文件</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<Xml Include="res\manifest.xml" />
</ItemGroup>
</Project> </Project>

View File

@@ -516,6 +516,7 @@ void TaskInstallPackage ()
{ {
wcerr << "\rError: Install Failed. Message: Unavailable Package." << endl; wcerr << "\rError: Install Failed. Message: Unavailable Package." << endl;
} }
} }
void TaskInstallPackages (size_t serial, size_t total) void TaskInstallPackages (size_t serial, size_t total)