Windows app and installer fixes (#3338)

* Windows app and installer fixes

* Sorted out comments
This commit is contained in:
Arkadiy Paronyan 2016-11-10 14:49:16 +01:00 committed by GitHub
parent 6ad909e7b3
commit bb5da2379b
2 changed files with 38 additions and 9 deletions

View File

@ -12,7 +12,7 @@
!define VERSIONMINOR 5 !define VERSIONMINOR 5
!define VERSIONBUILD 0 !define VERSIONBUILD 0
!define ARGS "--warp" !define ARGS "--warp"
!define FIRST_START_ARGS "--warp --mode=passive" !define FIRST_START_ARGS "ui --warp --mode=passive"
!addplugindir .\ !addplugindir .\
@ -160,6 +160,9 @@ section "uninstall"
!insertmacro TerminateApp !insertmacro TerminateApp
# Remove Start Menu launcher # Remove Start Menu launcher
delete "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk" delete "$SMPROGRAMS\${COMPANYNAME}\${APPNAME}.lnk"
delete "$SMPROGRAMS\${COMPANYNAME}\${APPNAME} Ethereum.lnk"
delete "$DESKTOP\${APPNAME} Ethereum.lnk"
# Try to remove the Start Menu folder - this will only happen if it is empty # Try to remove the Start Menu folder - this will only happen if it is empty
rmDir "$SMPROGRAMS\${COMPANYNAME}" rmDir "$SMPROGRAMS\${COMPANYNAME}"

View File

@ -41,6 +41,7 @@ DWORD parityProcId = 0;
NOTIFYICONDATA nidApp; NOTIFYICONDATA nidApp;
WCHAR szTitle[MAX_LOADSTRING]; WCHAR szTitle[MAX_LOADSTRING];
WCHAR szWindowClass[MAX_LOADSTRING]; WCHAR szWindowClass[MAX_LOADSTRING];
LPCWCHAR commandLineFiltered = L"";
LPCWSTR cParityExe = _T("parity.exe"); LPCWSTR cParityExe = _T("parity.exe");
@ -86,7 +87,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
return 0; return 0;
} }
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadStringW(hInstance, IDC_PTRAY, szWindowClass, MAX_LOADSTRING); LoadStringW(hInstance, IDC_PTRAY, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance); MyRegisterClass(hInstance);
@ -133,6 +133,24 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
bool InitInstance(HINSTANCE hInstance, int nCmdShow, LPWSTR cmdLine) bool InitInstance(HINSTANCE hInstance, int nCmdShow, LPWSTR cmdLine)
{ {
if (lstrlen(cmdLine) > 0)
{
int commandLineArgs = 0;
LPWSTR* commandLine = CommandLineToArgvW(cmdLine, &commandLineArgs);
LPWSTR filteredArgs = new WCHAR[lstrlen(cmdLine) + 2];
filteredArgs[0] = '\0';
for (int i = 0; i < commandLineArgs; i++)
{
// Remove "ui" from command line
if (lstrcmp(commandLine[i], L"ui") != 0)
{
lstrcat(filteredArgs, commandLine[i]);
lstrcat(filteredArgs, L" ");
}
}
commandLineFiltered = filteredArgs;
}
// Check if already running // Check if already running
PROCESSENTRY32 entry; PROCESSENTRY32 entry;
entry.dwSize = sizeof(PROCESSENTRY32); entry.dwSize = sizeof(PROCESSENTRY32);
@ -190,7 +208,9 @@ bool InitInstance(HINSTANCE hInstance, int nCmdShow, LPWSTR cmdLine)
nidApp.uCallbackMessage = WM_USER_SHELLICON; nidApp.uCallbackMessage = WM_USER_SHELLICON;
LoadString(hInstance, IDS_CONTROL_PARITY, nidApp.szTip, MAX_LOADSTRING); LoadString(hInstance, IDS_CONTROL_PARITY, nidApp.szTip, MAX_LOADSTRING);
Shell_NotifyIcon(NIM_ADD, &nidApp); Shell_NotifyIcon(NIM_ADD, &nidApp);
return TRUE;
SetTimer(hWnd, 0, 1000, nullptr);
return true;
} }
@ -294,8 +314,10 @@ void OpenUI()
PROCESS_INFORMATION procInfo = { 0 }; PROCESS_INFORMATION procInfo = { 0 };
STARTUPINFO startupInfo = { sizeof(STARTUPINFO) }; STARTUPINFO startupInfo = { sizeof(STARTUPINFO) };
LPWSTR cmd = _T("parity.exe ui"); LPWSTR args = new WCHAR[lstrlen(commandLineFiltered) + MAX_PATH + 2];
CreateProcess(path, cmd, nullptr, nullptr, false, CREATE_NO_WINDOW, nullptr, nullptr, &startupInfo, &procInfo); lstrcpy(args, L"parity.exe ui ");
lstrcat(args, commandLineFiltered);
CreateProcess(path, args, nullptr, nullptr, false, CREATE_NO_WINDOW, nullptr, nullptr, &startupInfo, &procInfo);
} }
bool AutostartEnabled() { bool AutostartEnabled() {
@ -321,10 +343,14 @@ void EnableAutostart(bool enable) {
if (enable) if (enable)
{ {
TCHAR path[MAX_PATH] = { 0 }; LPWSTR args = new WCHAR[lstrlen(commandLineFiltered) + MAX_PATH + 2];
if (!GetTrayExePath(path, MAX_PATH)) if (GetTrayExePath(args, MAX_PATH))
return; {
RegSetValueEx(hKey, L"Parity", 0, REG_SZ, (LPBYTE)path, MAX_PATH); lstrcat(args, L" ");
lstrcat(args, commandLineFiltered);
RegSetValueEx(hKey, L"Parity", 0, REG_SZ, (LPBYTE)args, MAX_PATH);
}
delete[] args;
} }
else else
{ {