summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-05-23 17:37:11 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-05-23 17:37:11 (GMT)
commita1b7b02f81500e0707cf4c98a943c17351c5505d (patch)
tree94d124ca2bd00672eb74a410b9358c051cb55c5b /src
parent4771b91d516f6946673d4d8e6135f5a596a1dd9b (diff)
downloadpowder-a1b7b02f81500e0707cf4c98a943c17351c5505d.zip
powder-a1b7b02f81500e0707cf4c98a943c17351c5505d.tar.gz
Windows installation, register ptsave URL protocol
Diffstat (limited to 'src')
-rw-r--r--src/misc.c55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/misc.c b/src/misc.c
index 290b29c..210e4d2 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -657,6 +657,7 @@ int register_extension()
char *currentfilename = exe_name();
char *iconname = NULL;
char *opencommand = NULL;
+ char *protocolcommand = NULL;
//char AppDataPath[MAX_PATH];
char *AppDataPath = NULL;
iconname = malloc(strlen(currentfilename)+6);
@@ -675,6 +676,7 @@ int register_extension()
//TODO: Implement
opencommand = malloc(strlen(currentfilename)+53+strlen(AppDataPath));
+ protocolcommand = malloc(strlen(currentfilename)+55+strlen(AppDataPath));
/*if((strlen(AppDataPath)+strlen(APPDATA_SUBDIR "\\Powder Toy"))<MAX_PATH)
{
strappend(AppDataPath, APPDATA_SUBDIR);
@@ -686,7 +688,57 @@ int register_extension()
goto finalise;
}*/
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
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\.cps", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
if (rresult != ERROR_SUCCESS) {
@@ -713,7 +765,7 @@ int register_extension()
goto finalise;
}
RegCloseKey(newkey);
-
+
//Create program entry
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
if (rresult != ERROR_SUCCESS) {
@@ -762,6 +814,7 @@ int register_extension()
if(iconname) free(iconname);
if(opencommand) free(opencommand);
if(currentfilename) free(currentfilename);
+ if(protocolcommand) free(protocolcommand);
return returnval;
#elif defined(LIN32) || defined(LIN64)