changeset 7:9e7373a5aa9f draft

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
author sirius-m <sirius-m@1a98c847-1fd6-4fd8-948a-caf3550aa51b>
date Sun, 04 Oct 2009 11:38:29 +0000
parents ec6b556dd7bf
children f718bedded34
files changelog.txt headers.h setup.nsi ui.cpp uibase.cpp uiproject.fbp
diffstat 6 files changed, 63 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/changelog.txt
+++ b/changelog.txt
@@ -2,5 +2,6 @@
 --------------------
 + 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
--- a/headers.h
+++ b/headers.h
@@ -37,7 +37,6 @@
 #include <assert.h>
 #include <process.h>
 #include <malloc.h>
-#include <shlobj.h>
 #include <memory>
 #define BOUNDSCHECK 1
 #include <sstream>
--- a/setup.nsi
+++ b/setup.nsi
@@ -53,7 +53,7 @@
 VIAddVersionKey FileVersion "${VERSION}"
 VIAddVersionKey FileDescription ""
 VIAddVersionKey LegalCopyright ""
-InstallDirRegKey HKLM "${REGKEY}" Path
+InstallDirRegKey HKCU "${REGKEY}" Path
 ShowUninstDetails show
 
 # Installer sections
@@ -63,32 +63,33 @@
     File bitcoin.exe
     File libeay32.dll
     File mingwm10.dll
-    WriteRegStr HKLM "${REGKEY}\Components" Main 1
+    WriteRegStr HKCU "${REGKEY}\Components" Main 1
+    WriteRegStr HKCU SOFTWARE\Microsoft\Windows\CurrentVersion\Run Bitcoin "$INSTDIR\bitcoin.exe /min"
 SectionEnd
 
 Section -post SEC0001
-    WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
+    WriteRegStr HKCU "${REGKEY}" Path $INSTDIR
     SetOutPath $INSTDIR
     WriteUninstaller $INSTDIR\uninstall.exe
     !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
-    SetOutPath $SMPROGRAMS\$StartMenuGroup
+    CreateDirectory $SMPROGRAMS\$StartMenuGroup
     CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk" $INSTDIR\bitcoin.exe
     CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall Bitcoin.lnk" $INSTDIR\uninstall.exe
     !insertmacro MUI_STARTMENU_WRITE_END
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe
-    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe
-    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
-    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe
+    WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe
+    WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
+    WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
 SectionEnd
 
 # Macro for selecting uninstaller sections
 !macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
     Push $R0
-    ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
+    ReadRegStr $R0 HKCU "${REGKEY}\Components" "${SECTION_NAME}"
     StrCmp $R0 1 0 next${UNSECTION_ID}
     !insertmacro SelectSection "${UNSECTION_ID}"
     GoTo done${UNSECTION_ID}
@@ -103,18 +104,20 @@
     Delete /REBOOTOK $INSTDIR\mingwm10.dll
     Delete /REBOOTOK $INSTDIR\libeay32.dll
     Delete /REBOOTOK $INSTDIR\bitcoin.exe
-    DeleteRegValue HKLM "${REGKEY}\Components" Main
+    DeleteRegValue HKCU "${REGKEY}\Components" Main
+    DeleteRegValue HKCU SOFTWARE\Microsoft\Windows\CurrentVersion\Run Bitcoin
 SectionEnd
 
 Section -un.post UNSEC0001
-    DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
+    DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
     Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall Bitcoin.lnk"
     Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Bitcoin.lnk"
     Delete /REBOOTOK $INSTDIR\uninstall.exe
-    DeleteRegValue HKLM "${REGKEY}" StartMenuGroup
-    DeleteRegValue HKLM "${REGKEY}" Path
-    DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
-    DeleteRegKey /IfEmpty HKLM "${REGKEY}"
+    Delete /REBOOTOK $INSTDIR\db.log
+    DeleteRegValue HKCU "${REGKEY}" StartMenuGroup
+    DeleteRegValue HKCU "${REGKEY}" Path
+    DeleteRegKey /IfEmpty HKCU "${REGKEY}\Components"
+    DeleteRegKey /IfEmpty HKCU "${REGKEY}"
     RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
     RmDir /REBOOTOK $INSTDIR
     Push $R0
@@ -131,7 +134,7 @@
 
 # Uninstaller functions
 Function un.onInit
-    ReadRegStr $INSTDIR HKLM "${REGKEY}" Path
+    ReadRegStr $INSTDIR HKCU "${REGKEY}" Path
     !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuGroup
     !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
 FunctionEnd
--- a/ui.cpp
+++ b/ui.cpp
@@ -3016,8 +3016,9 @@
 wxMenu *CBitcoinTBIcon::CreatePopupMenu()
 {
     wxMenu *menu = new wxMenu;
+    menu->Append(PU_RESTORE, _T("Open Bitcoin"));
     wxMenuItem* generateCheck = menu->AppendCheckItem(PU_GENERATE, _T("Generate Coins"));
-    menu->Append(PU_RESTORE, _T("Open Bitcoin"));
+    menu->InsertSeparator(2);
     menu->Append(PU_EXIT,    _T("Exit"));
 
     generateCheck->Check(fGenerateBitcoins);
@@ -3386,51 +3387,39 @@
 		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<void**>(&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<void**>(&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)
+					);
 		}
-		CoUninitialize();
+		else {
+			RegDeleteValue(hKey, "Bitcoin");
+		}
 	}
+	RegCloseKey(hKey);
 }
 
 
--- a/uibase.cpp
+++ b/uibase.cpp
@@ -1870,7 +1870,7 @@
 	
 	bSizer57->Add( m_checkCloseToTray, 0, wxALL, 5 );
 	
-	m_checkStartOnSysBoot = new wxCheckBox( this, wxID_ANY, wxT("Start on system boot"), wxDefaultPosition, wxDefaultSize, 0 );
+	m_checkStartOnSysBoot = new wxCheckBox( this, wxID_ANY, wxT("Start with Windows"), wxDefaultPosition, wxDefaultSize, 0 );
 	
 	bSizer57->Add( m_checkStartOnSysBoot, 0, wxALL, 5 );
 	
--- a/uiproject.fbp
+++ b/uiproject.fbp
@@ -11849,7 +11849,7 @@
                 </object>
             </object>
         </object>
-        <object class="Panel" expanded="1">
+        <object class="Panel" expanded="0">
             <property name="bg"></property>
             <property name="context_help"></property>
             <property name="enabled">1</property>
@@ -12076,7 +12076,7 @@
                 </object>
             </object>
         </object>
-        <object class="Panel" expanded="1">
+        <object class="Panel" expanded="0">
             <property name="bg"></property>
             <property name="context_help"></property>
             <property name="enabled">1</property>
@@ -12250,7 +12250,7 @@
                         <property name="font"></property>
                         <property name="hidden">0</property>
                         <property name="id">wxID_ANY</property>
-                        <property name="label">Start on system boot</property>
+                        <property name="label">Start with Windows</property>
                         <property name="maximum_size"></property>
                         <property name="minimum_size"></property>
                         <property name="name">m_checkStartOnSysBoot</property>