Corrected startup executable

This commit is contained in:
arkpar 2016-11-09 01:11:20 +01:00
parent 9325fe44f3
commit ad18a30535

View File

@ -63,6 +63,14 @@ bool GetParityExePath(TCHAR* dest, size_t destSize)
return PathAppend(dest, _T("parity.exe")) == TRUE; return PathAppend(dest, _T("parity.exe")) == TRUE;
} }
bool GetTrayExePath(TCHAR* dest, size_t destSize)
{
if (!dest || MAX_PATH > destSize)
return false;
GetModuleFileName(NULL, dest, (DWORD)destSize);
return true;
}
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance, _In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine, _In_ LPWSTR lpCmdLine,
@ -311,9 +319,10 @@ void EnableAutostart(bool enable) {
if (lRes != ERROR_SUCCESS) if (lRes != ERROR_SUCCESS)
return; return;
if (enable) { if (enable)
{
TCHAR path[MAX_PATH] = { 0 }; TCHAR path[MAX_PATH] = { 0 };
if (!GetParityExePath(path, MAX_PATH)) if (!GetTrayExePath(path, MAX_PATH))
return; return;
RegSetValueEx(hKey, L"Parity", 0, REG_SZ, (LPBYTE)path, MAX_PATH); RegSetValueEx(hKey, L"Parity", 0, REG_SZ, (LPBYTE)path, MAX_PATH);
} }