Skip to content

Commit

Permalink
Windows app and installer fixes (openethereum#3338)
Browse files Browse the repository at this point in the history
* Windows app and installer fixes

* Sorted out comments
  • Loading branch information
arkpar authored Nov 10, 2016
1 parent 6ad909e commit bb5da23
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
5 changes: 4 additions & 1 deletion nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
!define VERSIONMINOR 5
!define VERSIONBUILD 0
!define ARGS "--warp"
!define FIRST_START_ARGS "--warp --mode=passive"
!define FIRST_START_ARGS "ui --warp --mode=passive"

!addplugindir .\

Expand Down Expand Up @@ -160,6 +160,9 @@ section "uninstall"
!insertmacro TerminateApp
# Remove Start Menu launcher
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
rmDir "$SMPROGRAMS\${COMPANYNAME}"

Expand Down
42 changes: 34 additions & 8 deletions windows/ptray/ptray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ DWORD parityProcId = 0;
NOTIFYICONDATA nidApp;
WCHAR szTitle[MAX_LOADSTRING];
WCHAR szWindowClass[MAX_LOADSTRING];
LPCWCHAR commandLineFiltered = L"";

LPCWSTR cParityExe = _T("parity.exe");

Expand Down Expand Up @@ -85,7 +86,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
OpenUI();
return 0;
}


LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadStringW(hInstance, IDC_PTRAY, szWindowClass, MAX_LOADSTRING);
Expand Down Expand Up @@ -133,6 +133,24 @@ ATOM MyRegisterClass(HINSTANCE hInstance)

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
PROCESSENTRY32 entry;
entry.dwSize = sizeof(PROCESSENTRY32);
Expand Down Expand Up @@ -190,7 +208,9 @@ bool InitInstance(HINSTANCE hInstance, int nCmdShow, LPWSTR cmdLine)
nidApp.uCallbackMessage = WM_USER_SHELLICON;
LoadString(hInstance, IDS_CONTROL_PARITY, nidApp.szTip, MAX_LOADSTRING);
Shell_NotifyIcon(NIM_ADD, &nidApp);
return TRUE;

SetTimer(hWnd, 0, 1000, nullptr);
return true;

}

Expand Down Expand Up @@ -294,8 +314,10 @@ void OpenUI()
PROCESS_INFORMATION procInfo = { 0 };
STARTUPINFO startupInfo = { sizeof(STARTUPINFO) };

LPWSTR cmd = _T("parity.exe ui");
CreateProcess(path, cmd, nullptr, nullptr, false, CREATE_NO_WINDOW, nullptr, nullptr, &startupInfo, &procInfo);
LPWSTR args = new WCHAR[lstrlen(commandLineFiltered) + MAX_PATH + 2];
lstrcpy(args, L"parity.exe ui ");
lstrcat(args, commandLineFiltered);
CreateProcess(path, args, nullptr, nullptr, false, CREATE_NO_WINDOW, nullptr, nullptr, &startupInfo, &procInfo);
}

bool AutostartEnabled() {
Expand All @@ -321,10 +343,14 @@ void EnableAutostart(bool enable) {

if (enable)
{
TCHAR path[MAX_PATH] = { 0 };
if (!GetTrayExePath(path, MAX_PATH))
return;
RegSetValueEx(hKey, L"Parity", 0, REG_SZ, (LPBYTE)path, MAX_PATH);
LPWSTR args = new WCHAR[lstrlen(commandLineFiltered) + MAX_PATH + 2];
if (GetTrayExePath(args, MAX_PATH))
{
lstrcat(args, L" ");
lstrcat(args, commandLineFiltered);
RegSetValueEx(hKey, L"Parity", 0, REG_SZ, (LPBYTE)args, MAX_PATH);
}
delete[] args;
}
else
{
Expand Down

0 comments on commit bb5da23

Please sign in to comment.