Added some file association for Windows, NOT TESTED YET
This commit is contained in:
parent
bc58ff1479
commit
66edafa4fa
@ -69,6 +69,12 @@ void strappend(char *dst, char *src);
|
||||
|
||||
void *file_load(char *fn, int *size);
|
||||
|
||||
void clipboard_push_text(char * text);
|
||||
|
||||
char * clipboard_pull_text();
|
||||
|
||||
int register_extension();
|
||||
|
||||
int cpu_check(void);
|
||||
|
||||
// a b
|
||||
|
72
src/misc.c
72
src/misc.c
@ -380,6 +380,78 @@ char * clipboard_pull_text()
|
||||
return "";
|
||||
}
|
||||
|
||||
int register_extension()
|
||||
{
|
||||
#if defined WIN32
|
||||
|
||||
LONG rresult;
|
||||
HKEY newkey;
|
||||
char *currentfilename;
|
||||
char *iconname;
|
||||
char *opencommand;
|
||||
currentfilename = exe_name();
|
||||
iconname = malloc(strlen(currentfilename)+3);
|
||||
opencommand = malloc(strlen(currentfilename)+13);
|
||||
sprintf(iconname, "%s,1", currentfilename);
|
||||
sprintf(opencommand, "\"%s\" open:\"%%1\"", currentfilename);
|
||||
|
||||
//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){
|
||||
return 0;
|
||||
}
|
||||
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)"PowderToySave", strlen("PowderToySave")+1);
|
||||
if(rresult != ERROR_SUCCESS){
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
}
|
||||
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){
|
||||
return 0;
|
||||
}
|
||||
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)"Powder Toy Save", strlen("Powder Toy Save")+1);
|
||||
if(rresult != ERROR_SUCCESS){
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
}
|
||||
RegCloseKey(newkey);
|
||||
|
||||
//Set DefaultIcon
|
||||
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave\\DefaultIcon", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||
if(rresult != ERROR_SUCCESS){
|
||||
return 0;
|
||||
}
|
||||
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)iconname, strlen(iconname)+1);
|
||||
if(rresult != ERROR_SUCCESS){
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
}
|
||||
RegCloseKey(newkey);
|
||||
|
||||
//Set Launch command
|
||||
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\PowderToySave\\shell\\open\\command", 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &newkey, NULL);
|
||||
if(rresult != ERROR_SUCCESS){
|
||||
return 0;
|
||||
}
|
||||
rresult = RegSetValueEx(newkey, 0, 0, REG_SZ, (LPBYTE)opencommand, strlen(opencommand)+1);
|
||||
if(rresult != ERROR_SUCCESS){
|
||||
RegCloseKey(newkey);
|
||||
return 0;
|
||||
}
|
||||
RegCloseKey(newkey);
|
||||
|
||||
return 1;
|
||||
#elif defined LIN32
|
||||
return 0;
|
||||
#elif defined LIN64
|
||||
return 0;
|
||||
#elif definded MACOSX
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
vector2d v2d_zero = {0,0};
|
||||
matrix2d m2d_identity = {1,0,0,1};
|
||||
|
Reference in New Issue
Block a user