From 0cc05617d17947d139d09f4ddcca7aeca755f00a Mon Sep 17 00:00:00 2001 From: sirius-m Date: Sun, 4 Oct 2009 11:38:29 +0000 Subject: Fixed the installer script and made the autostart registry based. git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@14 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- ui.cpp | 77 ++++++++++++++++++++++++++++-------------------------------------- 1 file changed, 33 insertions(+), 44 deletions(-) (limited to 'ui.cpp') diff --git a/ui.cpp b/ui.cpp index e7be55da3c..a1e582ab9f 100644 --- a/ui.cpp +++ b/ui.cpp @@ -3016,8 +3016,9 @@ void CBitcoinTBIcon::UpdateTooltip() { wxMenu *CBitcoinTBIcon::CreatePopupMenu() { wxMenu *menu = new wxMenu; - wxMenuItem* generateCheck = menu->AppendCheckItem(PU_GENERATE, _T("Generate Coins")); menu->Append(PU_RESTORE, _T("Open Bitcoin")); + wxMenuItem* generateCheck = menu->AppendCheckItem(PU_GENERATE, _T("Generate Coins")); + menu->InsertSeparator(2); menu->Append(PU_EXIT, _T("Exit")); generateCheck->Check(fGenerateBitcoins); @@ -3386,51 +3387,39 @@ void ApplyUISettings() { taskBarIcon->Hide(); // Autostart on system startup? - // Get the startup folder shortcut path - char linkPath[ MAX_PATH ]; - SHGetSpecialFolderPath(0, linkPath, CSIDL_STARTUP, 0); - strcat(linkPath, "\\Bitcoin.lnk"); - - // If the shortcut exists already, remove it for updating - remove(linkPath); - - if (startOnSysBoot) { - CoInitialize(NULL); - // Get the current executable path - char exePath[ MAX_PATH ]; - GetModuleFileName(NULL, exePath, _MAX_PATH + 1); - - HRESULT hres = NULL; - IShellLink* psl = NULL; - // Get a pointer to the IShellLink interface. - hres = CoCreateInstance(CLSID_ShellLink, NULL, - CLSCTX_INPROC_SERVER, IID_IShellLink, - reinterpret_cast(&psl)); - - if (SUCCEEDED(hres)) - { - IPersistFile* ppf = NULL; - // Set the path to the shortcut target - psl->SetPath(exePath); - psl->SetArguments("/min"); - // Query IShellLink for the IPersistFile interface for - // saving the shortcut in persistent storage. - hres = psl->QueryInterface(IID_IPersistFile, - reinterpret_cast(&ppf)); - if (SUCCEEDED(hres)) - { - WCHAR wsz[MAX_PATH]; - // Ensure that the string is ANSI. - MultiByteToWideChar(CP_ACP, 0, linkPath, -1, - wsz, MAX_PATH); - // Save the link by calling IPersistFile::Save. - hres = ppf->Save(wsz, TRUE); - ppf->Release(); - } - psl->Release(); + // Open the startup registry key + HKEY hKey; + LONG lnRes = RegOpenKeyEx( + HKEY_CURRENT_USER, + "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", + 0, + KEY_ALL_ACCESS, + &hKey + ); + + if ( ERROR_SUCCESS == lnRes ) + { + if (startOnSysBoot) { + // Get the current executable path + char exePath[ MAX_PATH ]; + GetModuleFileName(NULL, exePath, _MAX_PATH + 1); + char runCmd[ MAX_PATH + 5 ]; + strcat(runCmd, exePath); + strcat(runCmd," /min"); + + RegSetValueEx(hKey, + "Bitcoin", + 0, + REG_SZ, + (BYTE*)runCmd, + sizeof(runCmd) + ); + } + else { + RegDeleteValue(hKey, "Bitcoin"); } - CoUninitialize(); } + RegCloseKey(hKey); } -- cgit v1.2.3