Fixed the installer script and made the autostart registry based.
authorsirius-m <sirius-m@1a98c847-1fd6-4fd8-948a-caf3550aa51b>
Sun, 4 Oct 2009 11:38:29 +0000 (11:38 +0000)
committersirius-m <sirius-m@1a98c847-1fd6-4fd8-948a-caf3550aa51b>
Sun, 4 Oct 2009 11:38:29 +0000 (11:38 +0000)
changelog.txt
headers.h
setup.nsi
ui.cpp
uibase.cpp
uiproject.fbp

index fee4f66..d2380b8 100644 (file)
@@ -2,5 +2,6 @@ Changes after 0.1.5:
 --------------------
 + Options dialog layout changed - added the UI options panel
 + Minimize to tray feature
-+ Startup on system boot feature (adds a shortcut to the Startup folder)
-+ Ask before closing
\ No newline at end of file
++ Startup on system boot feature
++ Ask before closing
++ NSIS installer
\ No newline at end of file
index 9291150..d0393c5 100644 (file)
--- a/headers.h
+++ b/headers.h
@@ -37,7 +37,6 @@
 #include <assert.h>\r
 #include <process.h>\r
 #include <malloc.h>\r
-#include <shlobj.h>\r
 #include <memory>\r
 #define BOUNDSCHECK 1\r
 #include <sstream>\r
index f49fe31..56a46ea 100644 (file)
--- a/setup.nsi
+++ b/setup.nsi
@@ -53,7 +53,7 @@ VIAddVersionKey CompanyWebsite "${URL}"
 VIAddVersionKey FileVersion "${VERSION}"\r
 VIAddVersionKey FileDescription ""\r
 VIAddVersionKey LegalCopyright ""\r
-InstallDirRegKey HKLM "${REGKEY}" Path\r
+InstallDirRegKey HKCU "${REGKEY}" Path\r
 ShowUninstDetails show\r
 \r
 # Installer sections\r
@@ -63,32 +63,33 @@ Section -Main SEC0000
     File bitcoin.exe\r
     File libeay32.dll\r
     File mingwm10.dll\r
-    WriteRegStr HKLM "${REGKEY}\Components" Main 1\r
+    WriteRegStr HKCU "${REGKEY}\Components" Main 1\r
+    WriteRegStr HKCU SOFTWARE\Microsoft\Windows\CurrentVersion\Run Bitcoin "$INSTDIR\bitcoin.exe /min"\r
 SectionEnd\r
 \r
 Section -post SEC0001\r
-    WriteRegStr HKLM "${REGKEY}" Path $INSTDIR\r
+    WriteRegStr HKCU "${REGKEY}" Path $INSTDIR\r
     SetOutPath $INSTDIR\r
     WriteUninstaller $INSTDIR\uninstall.exe\r
     !insertmacro MUI_STARTMENU_WRITE_BEGIN Application\r
-    SetOutPath $SMPROGRAMS\$StartMenuGroup\r
+    CreateDirectory $SMPROGRAMS\$StartMenuGroup\r
     CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk" $INSTDIR\bitcoin.exe\r
     CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall Bitcoin.lnk" $INSTDIR\uninstall.exe\r
     !insertmacro MUI_STARTMENU_WRITE_END\r
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"\r
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"\r
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"\r
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"\r
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe\r
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe\r
-    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1\r
-    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1\r
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"\r
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"\r
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"\r
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"\r
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe\r
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe\r
+    WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1\r
+    WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1\r
 SectionEnd\r
 \r
 # Macro for selecting uninstaller sections\r
 !macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID\r
     Push $R0\r
-    ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"\r
+    ReadRegStr $R0 HKCU "${REGKEY}\Components" "${SECTION_NAME}"\r
     StrCmp $R0 1 0 next${UNSECTION_ID}\r
     !insertmacro SelectSection "${UNSECTION_ID}"\r
     GoTo done${UNSECTION_ID}\r
@@ -103,18 +104,20 @@ Section /o -un.Main UNSEC0000
     Delete /REBOOTOK $INSTDIR\mingwm10.dll\r
     Delete /REBOOTOK $INSTDIR\libeay32.dll\r
     Delete /REBOOTOK $INSTDIR\bitcoin.exe\r
-    DeleteRegValue HKLM "${REGKEY}\Components" Main\r
+    DeleteRegValue HKCU "${REGKEY}\Components" Main\r
+    DeleteRegValue HKCU SOFTWARE\Microsoft\Windows\CurrentVersion\Run Bitcoin\r
 SectionEnd\r
 \r
 Section -un.post UNSEC0001\r
-    DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"\r
+    DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"\r
     Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall Bitcoin.lnk"\r
     Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk"\r
     Delete /REBOOTOK $INSTDIR\uninstall.exe\r
-    DeleteRegValue HKLM "${REGKEY}" StartMenuGroup\r
-    DeleteRegValue HKLM "${REGKEY}" Path\r
-    DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"\r
-    DeleteRegKey /IfEmpty HKLM "${REGKEY}"\r
+    Delete /REBOOTOK $INSTDIR\db.log\r
+    DeleteRegValue HKCU "${REGKEY}" StartMenuGroup\r
+    DeleteRegValue HKCU "${REGKEY}" Path\r
+    DeleteRegKey /IfEmpty HKCU "${REGKEY}\Components"\r
+    DeleteRegKey /IfEmpty HKCU "${REGKEY}"\r
     RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup\r
     RmDir /REBOOTOK $INSTDIR\r
     Push $R0\r
@@ -131,7 +134,7 @@ FunctionEnd
 \r
 # Uninstaller functions\r
 Function un.onInit\r
-    ReadRegStr $INSTDIR HKLM "${REGKEY}" Path\r
+    ReadRegStr $INSTDIR HKCU "${REGKEY}" Path\r
     !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuGroup\r
     !insertmacro SELECT_UNSECTION Main ${UNSEC0000}\r
 FunctionEnd\r
diff --git a/ui.cpp b/ui.cpp
index e7be55d..a1e582a 100644 (file)
--- a/ui.cpp
+++ b/ui.cpp
@@ -3016,8 +3016,9 @@ void CBitcoinTBIcon::UpdateTooltip() {
 wxMenu *CBitcoinTBIcon::CreatePopupMenu()\r
 {\r
     wxMenu *menu = new wxMenu;\r
-    wxMenuItem* generateCheck = menu->AppendCheckItem(PU_GENERATE, _T("Generate Coins"));\r
     menu->Append(PU_RESTORE, _T("Open Bitcoin"));\r
+    wxMenuItem* generateCheck = menu->AppendCheckItem(PU_GENERATE, _T("Generate Coins"));\r
+    menu->InsertSeparator(2);\r
     menu->Append(PU_EXIT,    _T("Exit"));\r
 \r
     generateCheck->Check(fGenerateBitcoins);\r
@@ -3386,51 +3387,39 @@ void ApplyUISettings() {
                taskBarIcon->Hide();\r
 \r
        // Autostart on system startup?\r
-       // Get the startup folder shortcut path\r
-       char linkPath[ MAX_PATH ];\r
-       SHGetSpecialFolderPath(0, linkPath, CSIDL_STARTUP, 0);\r
-       strcat(linkPath, "\\Bitcoin.lnk");\r
-\r
-       // If the shortcut exists already, remove it for updating\r
-       remove(linkPath);\r
-\r
-       if (startOnSysBoot) {\r
-               CoInitialize(NULL);\r
-               // Get the current executable path\r
-               char exePath[ MAX_PATH ];\r
-               GetModuleFileName(NULL, exePath, _MAX_PATH + 1);\r
-\r
-               HRESULT hres = NULL;\r
-               IShellLink* psl = NULL;\r
-               // Get a pointer to the IShellLink interface.\r
-               hres = CoCreateInstance(CLSID_ShellLink, NULL,\r
-                               CLSCTX_INPROC_SERVER, IID_IShellLink,\r
-                               reinterpret_cast<void**>(&psl));\r
-\r
-               if (SUCCEEDED(hres))\r
-               {\r
-                       IPersistFile* ppf = NULL;\r
-                       // Set the path to the shortcut target\r
-                       psl->SetPath(exePath);\r
-                       psl->SetArguments("/min");\r
-                       // Query IShellLink for the IPersistFile interface for\r
-                       // saving the shortcut in persistent storage.\r
-                       hres = psl->QueryInterface(IID_IPersistFile,\r
-                                       reinterpret_cast<void**>(&ppf));\r
-                       if (SUCCEEDED(hres))\r
-                       {\r
-                               WCHAR wsz[MAX_PATH];\r
-                               // Ensure that the string is ANSI.\r
-                               MultiByteToWideChar(CP_ACP, 0, linkPath, -1,\r
-                                               wsz, MAX_PATH);\r
-                               // Save the link by calling IPersistFile::Save.\r
-                               hres = ppf->Save(wsz, TRUE);\r
-                               ppf->Release();\r
-                       }\r
-                       psl->Release();\r
+       // Open the startup registry key\r
+       HKEY hKey;\r
+       LONG lnRes = RegOpenKeyEx(\r
+                       HKEY_CURRENT_USER,\r
+                       "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",\r
+                       0,\r
+                       KEY_ALL_ACCESS,\r
+                       &hKey\r
+       );\r
+\r
+       if ( ERROR_SUCCESS == lnRes )\r
+       {\r
+               if (startOnSysBoot) {\r
+                       // Get the current executable path\r
+                       char exePath[ MAX_PATH ];\r
+                       GetModuleFileName(NULL, exePath, _MAX_PATH + 1);\r
+                       char runCmd[ MAX_PATH + 5 ];\r
+                       strcat(runCmd, exePath);\r
+                       strcat(runCmd," /min");\r
+\r
+                       RegSetValueEx(hKey,\r
+                                       "Bitcoin",\r
+                                       0,\r
+                                       REG_SZ,\r
+                                       (BYTE*)runCmd,\r
+                                       sizeof(runCmd)\r
+                                       );\r
+               }\r
+               else {\r
+                       RegDeleteValue(hKey, "Bitcoin");\r
                }\r
-               CoUninitialize();\r
        }\r
+       RegCloseKey(hKey);\r
 }\r
 \r
 \r
index dcaa697..a88c67e 100644 (file)
@@ -1870,7 +1870,7 @@ COptionsPanelUIBase::COptionsPanelUIBase( wxWindow* parent, wxWindowID id, const
        \r
        bSizer57->Add( m_checkCloseToTray, 0, wxALL, 5 );\r
        \r
-       m_checkStartOnSysBoot = new wxCheckBox( this, wxID_ANY, wxT("Start on system boot"), wxDefaultPosition, wxDefaultSize, 0 );\r
+       m_checkStartOnSysBoot = new wxCheckBox( this, wxID_ANY, wxT("Start with Windows"), wxDefaultPosition, wxDefaultSize, 0 );\r
        \r
        bSizer57->Add( m_checkStartOnSysBoot, 0, wxALL, 5 );\r
        \r
index ccd8b22..315cc72 100644 (file)
                 </object>\r
             </object>\r
         </object>\r
-        <object class="Panel" expanded="1">\r
+        <object class="Panel" expanded="0">\r
             <property name="bg"></property>\r
             <property name="context_help"></property>\r
             <property name="enabled">1</property>\r
                 </object>\r
             </object>\r
         </object>\r
-        <object class="Panel" expanded="1">\r
+        <object class="Panel" expanded="0">\r
             <property name="bg"></property>\r
             <property name="context_help"></property>\r
             <property name="enabled">1</property>\r
                         <property name="font"></property>\r
                         <property name="hidden">0</property>\r
                         <property name="id">wxID_ANY</property>\r
-                        <property name="label">Start on system boot</property>\r
+                        <property name="label">Start with Windows</property>\r
                         <property name="maximum_size"></property>\r
                         <property name="minimum_size"></property>\r
                         <property name="name">m_checkStartOnSysBoot</property>\r