Fix file type associations for Windows Vista.
Use Chip-Like icon from shell32.dll for all ROMs.
This commit is contained in:
parent
4d4f53425e
commit
daa8105c07
|
@ -95,7 +95,8 @@ void Associate::OnOk()
|
||||||
commandPath.Format("\"%s\" \"%%1\"", applicationPath);
|
commandPath.Format("\"%s\" \"%%1\"", applicationPath);
|
||||||
regAssociateType("VisualBoyAdvance.Binary",
|
regAssociateType("VisualBoyAdvance.Binary",
|
||||||
"Binary",
|
"Binary",
|
||||||
commandPath);
|
commandPath,
|
||||||
|
"%SystemRoot%\\system32\\SHELL32.dll,-13");
|
||||||
|
|
||||||
for(int i = 0; i < 7; i++) {
|
for(int i = 0; i < 7; i++) {
|
||||||
if(mask & (1<<i)) {
|
if(mask & (1<<i)) {
|
||||||
|
|
|
@ -218,74 +218,108 @@ 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;
|
HKEY key;
|
||||||
LONG res = RegCreateKeyEx(HKEY_CLASSES_ROOT,
|
CString temp;
|
||||||
ext,
|
temp.Format( "Software\\Classes\\%s", ext );
|
||||||
|
LONG res = RegCreateKeyEx(
|
||||||
|
HKEY_CURRENT_USER,
|
||||||
|
temp,
|
||||||
0,
|
0,
|
||||||
"",
|
NULL,
|
||||||
REG_OPTION_NON_VOLATILE,
|
REG_OPTION_NON_VOLATILE,
|
||||||
KEY_ALL_ACCESS,
|
KEY_ALL_ACCESS,
|
||||||
NULL,
|
NULL,
|
||||||
&key,
|
&key,
|
||||||
&disp);
|
NULL );
|
||||||
if(res == ERROR_SUCCESS) {
|
if( res == ERROR_SUCCESS ) {
|
||||||
res = RegSetValueEx(key,
|
RegSetValueEx(
|
||||||
|
key,
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
REG_SZ,
|
REG_SZ,
|
||||||
(const UCHAR *)type,
|
(const BYTE *)type,
|
||||||
lstrlen(type)+1);
|
lstrlen(type) + 1 );
|
||||||
RegCloseKey(key);
|
RegCloseKey( key );
|
||||||
|
// Notify Windows that extensions have changed
|
||||||
|
SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
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;
|
HKEY key;
|
||||||
LONG res = RegCreateKeyEx(HKEY_CLASSES_ROOT,
|
CString temp;
|
||||||
type,
|
temp.Format( "Software\\Classes\\%s", type );
|
||||||
|
LONG res = RegCreateKeyEx(
|
||||||
|
HKEY_CURRENT_USER,
|
||||||
|
temp,
|
||||||
0,
|
0,
|
||||||
"",
|
NULL,
|
||||||
REG_OPTION_NON_VOLATILE,
|
REG_OPTION_NON_VOLATILE,
|
||||||
KEY_ALL_ACCESS,
|
KEY_ALL_ACCESS,
|
||||||
NULL,
|
NULL,
|
||||||
&key,
|
&key,
|
||||||
&disp);
|
NULL );
|
||||||
if(res == ERROR_SUCCESS) {
|
if( res == ERROR_SUCCESS ) {
|
||||||
res = RegSetValueEx(key,
|
res = RegSetValueEx(
|
||||||
"",
|
key,
|
||||||
|
"",//"FriendlyTypeName",
|
||||||
0,
|
0,
|
||||||
REG_SZ,
|
REG_SZ,
|
||||||
(const UCHAR *)desc,
|
(const BYTE *)desc,
|
||||||
lstrlen(desc)+1);
|
lstrlen(desc) + 1 );
|
||||||
HKEY key2;
|
HKEY key2;
|
||||||
res = RegCreateKeyEx(key,
|
res = RegCreateKeyEx(
|
||||||
|
key,
|
||||||
"Shell\\Open\\Command",
|
"Shell\\Open\\Command",
|
||||||
0,
|
0,
|
||||||
"",
|
NULL,
|
||||||
REG_OPTION_NON_VOLATILE,
|
REG_OPTION_NON_VOLATILE,
|
||||||
KEY_ALL_ACCESS,
|
KEY_ALL_ACCESS,
|
||||||
NULL,
|
NULL,
|
||||||
&key2,
|
&key2,
|
||||||
&disp);
|
NULL );
|
||||||
if(res == ERROR_SUCCESS) {
|
if( res == ERROR_SUCCESS ) {
|
||||||
res = RegSetValueEx(key2,
|
RegSetValueEx(
|
||||||
|
key2,
|
||||||
"",
|
"",
|
||||||
0,
|
0,
|
||||||
REG_SZ,
|
REG_SZ,
|
||||||
(const UCHAR *)application,
|
(const BYTE *)application,
|
||||||
lstrlen(application)+1);
|
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(key2);
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
|
// Notify Windows that extensions have changed
|
||||||
|
SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -12,7 +12,7 @@ void regSetBinaryValue(const char *key, char *value, int count);
|
||||||
void regDeleteValue(char *key);
|
void regDeleteValue(char *key);
|
||||||
void regInit(const char *);
|
void regInit(const char *);
|
||||||
void regShutdown();
|
void regShutdown();
|
||||||
bool regCreateFileType(const char *ext, const char *type);
|
bool regCreateFileType( const char *ext, const char *type );
|
||||||
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 = NULL );
|
||||||
void regExportSettingsToINI();
|
void regExportSettingsToINI();
|
||||||
#endif // VBA_REG_H
|
#endif // VBA_REG_H
|
||||||
|
|
Loading…
Reference in New Issue