Also register .stm extension in Windows

This commit is contained in:
jacksonmj 2011-04-06 15:21:42 +01:00 committed by Simon
parent 29e41a0a0c
commit 4aeac8b316
3 changed files with 14 additions and 6 deletions

View File

@ -20,7 +20,7 @@
#ifndef UPDATE_H #ifndef UPDATE_H
#define UPDATE_H #define UPDATE_H
static char *exe_name(void); char *exe_name(void);
int update_start(char *data, int len); int update_start(char *data, int len);
int update_finish(void); int update_finish(void);
void update_cleanup(void); void update_cleanup(void);

View File

@ -419,12 +419,9 @@ int register_extension()
#if defined WIN32 #if defined WIN32
LONG rresult; LONG rresult;
HKEY newkey; HKEY newkey;
char currentfilename[MAX_PATH] = ""; char *currentfilename = exe_name();
char *iconname; char *iconname;
char *opencommand; char *opencommand;
if (!GetModuleFileName(NULL, currentfilename, MAX_PATH))
return 0;
currentfilename[MAX_PATH-1] = 0;
iconname = malloc(strlen(currentfilename)+6); iconname = malloc(strlen(currentfilename)+6);
opencommand = malloc(strlen(currentfilename)+13); opencommand = malloc(strlen(currentfilename)+13);
sprintf(iconname, "%s,-102", currentfilename); sprintf(iconname, "%s,-102", currentfilename);
@ -442,6 +439,17 @@ int register_extension()
} }
RegCloseKey(newkey); RegCloseKey(newkey);
rresult = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\Classes\\.stm", 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 //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) {

View File

@ -39,7 +39,7 @@
#include <update.h> #include <update.h>
static char *exe_name(void) char *exe_name(void)
{ {
#if defined WIN32 #if defined WIN32
char *name= (char *)malloc(64), max=64, res; char *name= (char *)malloc(64), max=64, res;