Shift responsibility for file associations to the installer

In the past, CiderPress managed its own file associations.  This is
the feature that launches CiderPress when you double-click on a ".shk"
file.  The installer ran "CiderPress -install" and "-uninstall" during
installation and removal to give CP a chance to establish and clean
up the necessary registry entries.

The code built with VS6 works fine.  The code built with VS2013 fails
with an access denied error.  It appears there have been some access
policy changes, and the older code is getting "grandfathered in".  This
is really something that the installer ought to be handling, though,
so rather than figure out how to fix CiderPress, I'm removing the
file type association code from CiderPress and letting DeployMaster
handle it.

This may be slightly less convenient for anyone who had reason to
change type associations frequently.  Modern versions of Windows have
relatively easy to use control panel UIs for adjusting types, and
the "advanced installation" feature of DeployMaster allows you to
un-check the types that you don't want to have associated with
CiderPress.

(...with one minor hitch: DeployMaster 4.2.2 only shows the first 9
associations, and CiderPress has 18.)

This change renders most of the registry-handling code obsolete, as
well as the "-install" / "-uninstall" handling.  I'm 99% sure I want
to go this way, but I'm keeping things #ifdefed rather than deleted
for the moment.
This commit is contained in:
Andy McFadden 2014-12-11 13:53:02 -08:00
parent a5fa12b332
commit 4638d03d6c
12 changed files with 280 additions and 20 deletions

View File

@ -321,7 +321,241 @@ TRUE
-
-
-
0
18
TRUE
.2mg
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.app
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.bny
Binary II (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
2
C:\Src\ciderpress\Release\CiderPress.exe
2
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.bqy
Binary II (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
2
C:\Src\ciderpress\Release\CiderPress.exe
2
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.bse
NuFX Archive (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
1
C:\Src\ciderpress\Release\CiderPress.exe
1
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.bxy
NuFX Archive (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
1
C:\Src\ciderpress\Release\CiderPress.exe
1
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.d13
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.ddd
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.do
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.dsk
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.fdi
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.hdv
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
FALSE
.img
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.nib
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.po
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.dsk
Disk Image (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
3
C:\Src\ciderpress\Release\CiderPress.exe
3
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
FALSE
.sea
NuFX Archive (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
1
C:\Src\ciderpress\Release\CiderPress.exe
1
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
TRUE
.shk
NuFX Archive (CiderPress)
C:\Src\ciderpress\Release\CiderPress.exe
1
C:\Src\ciderpress\Release\CiderPress.exe
1
1
Open
Open
C:\Src\ciderpress\Release\CiderPress.exe
C:\Src\ciderpress\Release\CiderPress.exe
"%1"
FALSE
FALSE
FALSE
@ -335,11 +569,11 @@ http://www.deploymaster.com/dotnetfx.html
TRUE
FALSE
TRUE
TRUE
FALSE
C:\Src\ciderpress\Release\CiderPress.exe
-install
C:\Src\ciderpress\Release\CiderPress.exe
-uninstall
TRUE

View File

@ -234,10 +234,10 @@ BEGIN
LTEXT "Using ASPI DLL v%ls",IDC_ASPI_VERS_TEXT,16,114,173,8
END
IDD_PREF_GENERAL DIALOG 0, 0, 263, 180
IDD_PREF_GENERAL DIALOGEX 0, 0, 263, 180
STYLE DS_SETFONT | DS_CONTEXTHELP | WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "General"
FONT 8, "MS Sans Serif"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
GROUPBOX "Columns",IDC_STATIC,4,7,80,144
CONTROL "Pathname",IDC_COL_PATHNAME,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,12,19,65,10
@ -261,13 +261,11 @@ BEGIN
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,104,72,144,8
CONTROL "Show spaces as &underscores",IDC_PREF_SPACES_TO_UNDER,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,104,84,145,10
GROUPBOX "System",IDC_STATIC,96,101,162,33
PUSHBUTTON "File type &associations...",IDC_PREF_ASSOCIATIONS,104,113,92,14
GROUPBOX "Miscellaneous",IDC_STATIC,96,136,162,38
GROUPBOX "Miscellaneous",IDC_STATIC,96,102,162,38
CONTROL "Strip pathnames when pasting files",IDC_PREF_PASTE_JUNKPATHS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,104,147,144,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,104,117,144,10
CONTROL "Beep when actions complete successfully",IDC_PREF_SUCCESS_BEEP,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,104,159,145,10
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,104,129,145,10
END
IDD_PREF_COMPRESSION DIALOGEX 0, 0, 212, 212

View File

@ -4,6 +4,7 @@
* See the file LICENSE for distribution terms.
*/
#include "stdafx.h"
#ifdef CAN_UPDATE_FILE_ASSOC
#include "EditAssocDialog.h"
#include "MyApp.h"
#include "Registry.h"
@ -118,3 +119,5 @@ void EditAssocDialog::DoDataExchange(CDataExchange* pDX)
}
}
}
#endif

View File

@ -8,7 +8,7 @@
*/
#ifndef APP_EDITASSOCDIALOG_H
#define APP_EDITASSOCDIALOG_H
#ifdef CAN_UPDATE_FILE_ASSOC
#include "resource.h"
/*
@ -53,4 +53,5 @@ protected:
DECLARE_MESSAGE_MAP()
};
#endif
#endif /*APP_EDITASSOCDIALOG_H*/

View File

@ -561,6 +561,7 @@ LONG MainWindow::OnLateInit(UINT, LONG)
*/
fPreferences.LoadFromRegistry();
#ifdef CAN_UPDATE_FILE_ASSOC
/*
* Check to see if we're registered; if we're not, and we've expired, it's
* time to bail out.
@ -596,6 +597,7 @@ LONG MainWindow::OnLateInit(UINT, LONG)
result = confused;
goto fail;
}
#endif /*CAN_UPDATE_FILE_ASSOC*/
/*
* Process command-line options, possibly loading an archive.
@ -865,11 +867,13 @@ void MainWindow::ApplyNow(PrefsSheet* pPS)
if (pPS->fGeneralPage.fOurAssociations != NULL) {
LOGI("NEW ASSOCIATIONS!");
#ifdef CAN_UPDATE_FILE_ASSOC
for (int assoc = 0; assoc < gMyApp.fRegistry.GetNumFileAssocs(); assoc++)
{
gMyApp.fRegistry.SetFileAssoc(assoc,
pPS->fGeneralPage.fOurAssociations[assoc]);
}
#endif
/* delete them so, if they hit "apply" again, we only update once */
delete[] pPS->fGeneralPage.fOurAssociations;

View File

@ -106,7 +106,9 @@ BOOL MyApp::InitInstance(void)
LOGI("WriteProfileString failed");
#endif
SetRegistryKey(fRegistry.GetAppRegistryKey());
// This causes functions like SetProfileInt to use the registry rather
// than a .INI file. The registry key is "usually the name of a company".
SetRegistryKey(L"faddenSoft");
//LOGI("Registry key is '%ls'", m_pszRegistryKey);
//LOGI("Profile name is '%ls'", m_pszProfileName);
@ -119,6 +121,7 @@ BOOL MyApp::InitInstance(void)
//if (!WriteProfileString("SectionOne", "MyEntry", "test"))
// LOGI("WriteProfileString failed");
#ifdef CAN_UPDATE_FILE_ASSOC
/*
* If we're installing or uninstalling, do what we need to and then
* bail immediately. This will hemorrhage memory, but I'm sure the
@ -135,6 +138,7 @@ BOOL MyApp::InitInstance(void)
}
fRegistry.FixBasicSettings();
#endif
return TRUE;
}

View File

@ -26,7 +26,9 @@ public:
MyApp(LPCTSTR lpszAppName = NULL);
virtual ~MyApp(void);
#ifdef CAN_UPDATE_FILE_ASSOC
MyRegistry fRegistry;
#endif
const WCHAR* GetExeFileName(void) const { return fExeFileName; }
const WCHAR* GetExeBaseName(void) const { return fExeBaseName; }

View File

@ -520,7 +520,7 @@ int Preferences::LoadFromRegistry(void)
GetString(fPrefMaps[i].registrySection, fPrefMaps[i].registryKey, sval));
break;
default:
LOGI("Invalid type %d on num=%d", fPrefMaps[i].type, i);
LOGW("Invalid type %d on num=%d", fPrefMaps[i].type, i);
ASSERT(false);
break;
}
@ -554,7 +554,7 @@ int Preferences::SaveToRegistry(void)
GetPrefString(fPrefMaps[i].num));
break;
default:
LOGI("Invalid type %d on num=%d", fPrefMaps[i].type, i);
LOGW("Invalid type %d on num=%d", fPrefMaps[i].type, i);
ASSERT(false);
break;
}

View File

@ -6,7 +6,9 @@
#include "stdafx.h"
#include "PrefsDialog.h"
#include "ChooseDirDialog.h"
#ifdef CAN_UPDATE_FILE_ASSOC
#include "EditAssocDialog.h"
#endif
#include "Main.h"
#include "NufxArchive.h"
#include "resource.h"
@ -29,7 +31,9 @@ BEGIN_MESSAGE_MAP(PrefsGeneralPage, CPropertyPage)
ON_BN_CLICKED(IDC_PREF_PASTE_JUNKPATHS, OnChange)
ON_BN_CLICKED(IDC_PREF_SUCCESS_BEEP, OnChange)
ON_BN_CLICKED(IDC_COL_DEFAULTS, OnDefaults)
#ifdef CAN_UPDATE_FILE_ASSOC
ON_BN_CLICKED(IDC_PREF_ASSOCIATIONS, OnAssociations)
#endif
ON_MESSAGE(WM_HELP, OnHelpInfo)
ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)
END_MESSAGE_MAP()
@ -75,6 +79,7 @@ void PrefsGeneralPage::OnDefaults(void)
SetModified(TRUE);
}
#ifdef CAN_UPDATE_FILE_ASSOC
void PrefsGeneralPage::OnAssociations(void)
{
EditAssocDialog assocDlg;
@ -94,6 +99,7 @@ void PrefsGeneralPage::OnAssociations(void)
SetModified(TRUE);
}
}
#endif
void PrefsGeneralPage::DoDataExchange(CDataExchange* pDX)
{

View File

@ -57,7 +57,9 @@ protected:
afx_msg void OnChange(void);
afx_msg void OnChangeRange(UINT);
afx_msg void OnDefaults(void);
#ifdef CAN_UPDATE_FILE_ASSOC
afx_msg void OnAssociations(void);
#endif
afx_msg LONG OnHelpInfo(UINT wParam, LONG lParam) {
return MyApp::HandleHelpInfo((HELPINFO*) lParam);
}

View File

@ -7,6 +7,7 @@
* Windows Registry operations.
*/
#include "stdafx.h"
#ifdef CAN_UPDATE_FILE_ASSOC
#include "Registry.h"
#include "Main.h"
#include "MyApp.h"
@ -212,15 +213,16 @@ void MyRegistry::FixBasicSettings(void) const
void MyRegistry::ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
const WCHAR* exeName, int iconIdx) const
{
LOGI(" Configuring '%ls' for '%ls'", appID, exeName);
LOGI(" ConfigureAppID '%ls' for '%ls'", appID, exeName);
HKEY hAppKey = NULL;
HKEY hIconKey = NULL;
DWORD dw;
if (RegCreateKeyEx(HKEY_CLASSES_ROOT, appID, 0, REG_NONE,
LONG result;
if ((result = RegCreateKeyEx(HKEY_CLASSES_ROOT, appID, 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hAppKey, &dw) == ERROR_SUCCESS)
&hAppKey, &dw)) == ERROR_SUCCESS)
{
ConfigureAppIDSubFields(hAppKey, descr, exeName);
@ -247,15 +249,15 @@ void MyRegistry::ConfigureAppID(const WCHAR* appID, const WCHAR* descr,
LOGI(" Set icon for '%ls' to '%ls'", appID,
(LPCWSTR) iconStr);
} else {
LOGI(" WARNING: unable to set DefaultIcon for '%ls' to '%ls'",
LOGW(" WARNING: unable to set DefaultIcon for '%ls' to '%ls'",
appID, (LPCWSTR) iconStr);
}
}
} else {
LOGI("WARNING: couldn't set up DefaultIcon for '%ls'", appID);
LOGW("WARNING: couldn't set up DefaultIcon for '%ls'", appID);
}
} else {
LOGI("WARNING: couldn't create AppID='%ls'", appID);
LOGW("WARNING: couldn't create AppID='%ls' (err=%ld)", appID, result);
}
RegCloseKey(hIconKey);
@ -619,3 +621,4 @@ DWORD MyRegistry::RegDeleteKeyNT(HKEY hStartKey, LPCTSTR pKeyName) const
return dwRtn;
}
#endif

View File

@ -9,6 +9,7 @@
#ifndef APP_REGISTRY_H
#define APP_REGISTRY_H
#ifdef CAN_UPDATE_FILE_ASSOC
/*
* All access to the registry (except for GetProfileInt/GetProfileString)
@ -160,4 +161,6 @@ private:
int VerifyKey(const char* user, const char* company, const char* key);
};
#endif
#endif /*APP_REGISTRY_H*/