From 71466498515b2489662e59fd2c5295dc85a61bb6 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 28 Feb 2006 21:51:21 +0000 Subject: [PATCH] fix installation reg values not written --- .../src/archutils/Win32/RegistryAccess.cpp | 26 +++++++++++++++++++ .../src/archutils/Win32/RegistryAccess.h | 2 ++ stepmania/src/smpackage/MainMenuDlg.cpp | 2 -- stepmania/src/smpackage/SMPackageUtil.cpp | 13 +++++----- stepmania/src/smpackage/smpackage.cpp | 1 + 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/stepmania/src/archutils/Win32/RegistryAccess.cpp b/stepmania/src/archutils/Win32/RegistryAccess.cpp index cf8819b5e6..25c7670af5 100644 --- a/stepmania/src/archutils/Win32/RegistryAccess.cpp +++ b/stepmania/src/archutils/Win32/RegistryAccess.cpp @@ -190,6 +190,32 @@ bool RegistryAccess::SetRegValue( const RString &sKey, const RString &sName, boo return bSuccess; } +bool RegistryAccess::CreateKey( const RString &sKey ) +{ + RString sSubkey; + HKEY hType; + if( !GetRegKeyType(sKey, sSubkey, hType) ) + return NULL; + + HKEY hKey; + DWORD dwDisposition = 0; + if( ::RegCreateKeyEx( + hType, + sSubkey, + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_ALL_ACCESS, + NULL, + &hKey, + &dwDisposition ) != ERROR_SUCCESS ) + { + return false; + } + ::RegCloseKey(hKey); + return true; +} + /* * (c) 2004 Glenn Maynard * All rights reserved. diff --git a/stepmania/src/archutils/Win32/RegistryAccess.h b/stepmania/src/archutils/Win32/RegistryAccess.h index 4680174c79..74f263b14e 100644 --- a/stepmania/src/archutils/Win32/RegistryAccess.h +++ b/stepmania/src/archutils/Win32/RegistryAccess.h @@ -14,6 +14,8 @@ namespace RegistryAccess bool SetRegValue( const RString &sKey, const RString &sName, const RString &val ); bool SetRegValue( const RString &sKey, const RString &sName, int val ); bool SetRegValue( const RString &sKey, const RString &sName, bool val ); + + bool CreateKey( const RString &sKey ); } #endif diff --git a/stepmania/src/smpackage/MainMenuDlg.cpp b/stepmania/src/smpackage/MainMenuDlg.cpp index 33475a4fc7..c7c3cf73da 100644 --- a/stepmania/src/smpackage/MainMenuDlg.cpp +++ b/stepmania/src/smpackage/MainMenuDlg.cpp @@ -179,8 +179,6 @@ BOOL MainMenuDlg::OnInitDialog() TCHAR szCurDir[MAX_PATH]; GetCurrentDirectory( ARRAYSIZE(szCurDir), szCurDir ); GetDlgItem( IDC_EDIT_INSTALLATION )->SetWindowText( szCurDir ); - SMPackageUtil::AddGameInstallDir( szCurDir ); - SMPackageUtil::SetDefaultInstallDir( szCurDir ); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE diff --git a/stepmania/src/smpackage/SMPackageUtil.cpp b/stepmania/src/smpackage/SMPackageUtil.cpp index 832757fabe..1168d02589 100644 --- a/stepmania/src/smpackage/SMPackageUtil.cpp +++ b/stepmania/src/smpackage/SMPackageUtil.cpp @@ -15,17 +15,16 @@ static const RString INSTALLATIONS_KEY = "HKEY_LOCAL_MACHINE\\Software\\" PRODUC void SMPackageUtil::WriteGameInstallDirs( const vector& asInstallDirsToWrite ) { + RegistryAccess::CreateKey( INSTALLATIONS_KEY ); + for( unsigned i=0; i<100; i++ ) { RString sName = ssprintf("%d",i); -// Reg.DeleteKey( sName ); // delete key is broken in this library, so just write over it with "" - RegistryAccess::SetRegValue( INSTALLATIONS_KEY, sName, RString() ); - } + RString sValue; + if( i < asInstallDirsToWrite.size() ) + sValue = asInstallDirsToWrite[i]; - for( unsigned i=0; i