Fix file type associations for Windows Vista.
Use Chip-Like icon from shell32.dll for all ROMs. git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@886 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
parent
0eccbe84bd
commit
f986277ed8
|
@ -95,7 +95,8 @@ void Associate::OnOk()
|
|||
commandPath.Format("\"%s\" \"%%1\"", applicationPath);
|
||||
regAssociateType("VisualBoyAdvance.Binary",
|
||||
"Binary",
|
||||
commandPath);
|
||||
commandPath,
|
||||
"%SystemRoot%\\system32\\SHELL32.dll,-13");
|
||||
|
||||
for(int i = 0; i < 7; i++) {
|
||||
if(mask & (1<<i)) {
|
||||
|
|
|
@ -218,77 +218,111 @@ void regDeleteValue(char *key)
|
|||
}
|
||||
}
|
||||
|
||||
bool regCreateFileType(const char *ext, const char *type)
|
||||
bool regCreateFileType( const char *ext, const char *type )
|
||||
{
|
||||
DWORD disp = 0;
|
||||
HKEY key;
|
||||
LONG res = RegCreateKeyEx(HKEY_CLASSES_ROOT,
|
||||
ext,
|
||||
0,
|
||||
"",
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&key,
|
||||
&disp);
|
||||
if(res == ERROR_SUCCESS) {
|
||||
res = RegSetValueEx(key,
|
||||
"",
|
||||
0,
|
||||
REG_SZ,
|
||||
(const UCHAR *)type,
|
||||
lstrlen(type)+1);
|
||||
RegCloseKey(key);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
HKEY key;
|
||||
CString temp;
|
||||
temp.Format( "Software\\Classes\\%s", ext );
|
||||
LONG res = RegCreateKeyEx(
|
||||
HKEY_CURRENT_USER,
|
||||
temp,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&key,
|
||||
NULL );
|
||||
if( res == ERROR_SUCCESS ) {
|
||||
RegSetValueEx(
|
||||
key,
|
||||
"",
|
||||
0,
|
||||
REG_SZ,
|
||||
(const BYTE *)type,
|
||||
lstrlen(type) + 1 );
|
||||
RegCloseKey( key );
|
||||
// Notify Windows that extensions have changed
|
||||
SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool regAssociateType(const char *type, const char *desc, const char *application)
|
||||
bool regAssociateType( const char *type, const char *desc, const char *application, const char *icon )
|
||||
{
|
||||
DWORD disp = 0;
|
||||
HKEY key;
|
||||
LONG res = RegCreateKeyEx(HKEY_CLASSES_ROOT,
|
||||
type,
|
||||
0,
|
||||
"",
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&key,
|
||||
&disp);
|
||||
if(res == ERROR_SUCCESS) {
|
||||
res = RegSetValueEx(key,
|
||||
"",
|
||||
0,
|
||||
REG_SZ,
|
||||
(const UCHAR *)desc,
|
||||
lstrlen(desc)+1);
|
||||
HKEY key2;
|
||||
res = RegCreateKeyEx(key,
|
||||
"Shell\\Open\\Command",
|
||||
0,
|
||||
"",
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&key2,
|
||||
&disp);
|
||||
if(res == ERROR_SUCCESS) {
|
||||
res = RegSetValueEx(key2,
|
||||
"",
|
||||
0,
|
||||
REG_SZ,
|
||||
(const UCHAR *)application,
|
||||
lstrlen(application)+1);
|
||||
RegCloseKey(key2);
|
||||
RegCloseKey(key);
|
||||
return true;
|
||||
}
|
||||
|
||||
RegCloseKey(key);
|
||||
}
|
||||
return false;
|
||||
HKEY key;
|
||||
CString temp;
|
||||
temp.Format( "Software\\Classes\\%s", type );
|
||||
LONG res = RegCreateKeyEx(
|
||||
HKEY_CURRENT_USER,
|
||||
temp,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&key,
|
||||
NULL );
|
||||
if( res == ERROR_SUCCESS ) {
|
||||
res = RegSetValueEx(
|
||||
key,
|
||||
"",//"FriendlyTypeName",
|
||||
0,
|
||||
REG_SZ,
|
||||
(const BYTE *)desc,
|
||||
lstrlen(desc) + 1 );
|
||||
HKEY key2;
|
||||
res = RegCreateKeyEx(
|
||||
key,
|
||||
"Shell\\Open\\Command",
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&key2,
|
||||
NULL );
|
||||
if( res == ERROR_SUCCESS ) {
|
||||
RegSetValueEx(
|
||||
key2,
|
||||
"",
|
||||
0,
|
||||
REG_SZ,
|
||||
(const BYTE *)application,
|
||||
lstrlen(application) + 1 );
|
||||
if( icon != NULL ) {
|
||||
HKEY key3;
|
||||
res = RegCreateKeyEx(
|
||||
key,
|
||||
"DefaultIcon",
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
&key3,
|
||||
NULL );
|
||||
if( res == ERROR_SUCCESS ) {
|
||||
RegSetValueEx(
|
||||
key3,
|
||||
"",
|
||||
0,
|
||||
REG_SZ,
|
||||
(const BYTE *)icon,
|
||||
lstrlen(icon) + 1 );
|
||||
}
|
||||
RegCloseKey(key3);
|
||||
}
|
||||
RegCloseKey(key2);
|
||||
RegCloseKey(key);
|
||||
// Notify Windows that extensions have changed
|
||||
SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL );
|
||||
return true;
|
||||
}
|
||||
RegCloseKey(key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void regExportSettingsToINI(HKEY key, const char *section)
|
||||
|
|
|
@ -12,7 +12,7 @@ void regSetBinaryValue(const char *key, char *value, int count);
|
|||
void regDeleteValue(char *key);
|
||||
void regInit(const char *);
|
||||
void regShutdown();
|
||||
bool regCreateFileType(const char *ext, const char *type);
|
||||
bool regAssociateType(const char *type, const char *desc, const char *application);
|
||||
bool regCreateFileType( const char *ext, const char *type );
|
||||
bool regAssociateType( const char *type, const char *desc, const char *application, const char *icon = NULL );
|
||||
void regExportSettingsToINI();
|
||||
#endif // VBA_REG_H
|
||||
|
|
Loading…
Reference in New Issue