mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-31 19:51:45 +02:00
Windows installation, register ptsave URL protocol
This commit is contained in:
55
src/misc.c
55
src/misc.c
@@ -657,6 +657,7 @@ int register_extension()
|
|||||||
char *currentfilename = exe_name();
|
char *currentfilename = exe_name();
|
||||||
char *iconname = NULL;
|
char *iconname = NULL;
|
||||||
char *opencommand = NULL;
|
char *opencommand = NULL;
|
||||||
|
char *protocolcommand = NULL;
|
||||||
//char AppDataPath[MAX_PATH];
|
//char AppDataPath[MAX_PATH];
|
||||||
char *AppDataPath = NULL;
|
char *AppDataPath = NULL;
|
||||||
iconname = malloc(strlen(currentfilename)+6);
|
iconname = malloc(strlen(currentfilename)+6);
|
||||||
@@ -675,6 +676,7 @@ int register_extension()
|
|||||||
//TODO: Implement
|
//TODO: Implement
|
||||||
|
|
||||||
opencommand = malloc(strlen(currentfilename)+53+strlen(AppDataPath));
|
opencommand = malloc(strlen(currentfilename)+53+strlen(AppDataPath));
|
||||||
|
protocolcommand = malloc(strlen(currentfilename)+55+strlen(AppDataPath));
|
||||||
/*if((strlen(AppDataPath)+strlen(APPDATA_SUBDIR "\\Powder Toy"))<MAX_PATH)
|
/*if((strlen(AppDataPath)+strlen(APPDATA_SUBDIR "\\Powder Toy"))<MAX_PATH)
|
||||||
{
|
{
|
||||||
strappend(AppDataPath, APPDATA_SUBDIR);
|
strappend(AppDataPath, APPDATA_SUBDIR);
|
||||||
@@ -686,7 +688,57 @@ int register_extension()
|
|||||||
goto finalise;
|
goto finalise;
|
||||||
}*/
|
}*/
|
||||||
sprintf(opencommand, "\"%s\" open \"%%1\" ddir \"%s\"", currentfilename, AppDataPath);
|
sprintf(opencommand, "\"%s\" open \"%%1\" ddir \"%s\"", currentfilename, AppDataPath);
|
||||||
|
sprintf(protocolcommand, "\"%s\" ddir \"%s\" ptsave \"%%1\"", currentfilename, AppDataPath);
|
||||||
|
|
||||||
|
//Create protocol entry
|
||||||
|
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\ptsave", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||||
|
if (rresult != ERROR_SUCCESS) {
|
||||||
|
returnval = 0;
|
||||||
|
goto finalise;
|
||||||
|
}
|
||||||
|
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)"Powder Toy Save", strlen("Powder Toy Save")+1);
|
||||||
|
if (rresult != ERROR_SUCCESS) {
|
||||||
|
RegCloseKey(newkey);
|
||||||
|
returnval = 0;
|
||||||
|
goto finalise;
|
||||||
|
}
|
||||||
|
rresult = RegSetValueEx(newkey, (LPBYTE)"URL Protocol", 0, REG_SZ, (LPBYTE)"", strlen("")+1);
|
||||||
|
if (rresult != ERROR_SUCCESS) {
|
||||||
|
RegCloseKey(newkey);
|
||||||
|
returnval = 0;
|
||||||
|
goto finalise;
|
||||||
|
}
|
||||||
|
RegCloseKey(newkey);
|
||||||
|
|
||||||
|
|
||||||
|
//Set Protocol DefaultIcon
|
||||||
|
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\ptsave\\DefaultIcon", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||||
|
if (rresult != ERROR_SUCCESS) {
|
||||||
|
returnval = 0;
|
||||||
|
goto finalise;
|
||||||
|
}
|
||||||
|
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)iconname, strlen(iconname)+1);
|
||||||
|
if (rresult != ERROR_SUCCESS) {
|
||||||
|
RegCloseKey(newkey);
|
||||||
|
returnval = 0;
|
||||||
|
goto finalise;
|
||||||
|
}
|
||||||
|
RegCloseKey(newkey);
|
||||||
|
|
||||||
|
//Set Protocol Launch command
|
||||||
|
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\ptsave\\shell\\open\\command", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||||
|
if (rresult != ERROR_SUCCESS) {
|
||||||
|
returnval = 0;
|
||||||
|
goto finalise;
|
||||||
|
}
|
||||||
|
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)protocolcommand, strlen(protocolcommand)+1);
|
||||||
|
if (rresult != ERROR_SUCCESS) {
|
||||||
|
RegCloseKey(newkey);
|
||||||
|
returnval = 0;
|
||||||
|
goto finalise;
|
||||||
|
}
|
||||||
|
RegCloseKey(newkey);
|
||||||
|
|
||||||
//Create extension entry
|
//Create extension entry
|
||||||
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\.cps", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\.cps", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||||
if (rresult != ERROR_SUCCESS) {
|
if (rresult != ERROR_SUCCESS) {
|
||||||
@@ -713,7 +765,7 @@ int register_extension()
|
|||||||
goto finalise;
|
goto finalise;
|
||||||
}
|
}
|
||||||
RegCloseKey(newkey);
|
RegCloseKey(newkey);
|
||||||
|
|
||||||
//Create program entry
|
//Create program entry
|
||||||
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||||
if (rresult != ERROR_SUCCESS) {
|
if (rresult != ERROR_SUCCESS) {
|
||||||
@@ -762,6 +814,7 @@ int register_extension()
|
|||||||
if(iconname) free(iconname);
|
if(iconname) free(iconname);
|
||||||
if(opencommand) free(opencommand);
|
if(opencommand) free(opencommand);
|
||||||
if(currentfilename) free(currentfilename);
|
if(currentfilename) free(currentfilename);
|
||||||
|
if(protocolcommand) free(protocolcommand);
|
||||||
|
|
||||||
return returnval;
|
return returnval;
|
||||||
#elif defined(LIN32) || defined(LIN64)
|
#elif defined(LIN32) || defined(LIN64)
|
||||||
|
Reference in New Issue
Block a user