From f535f8dce4e8c86a361003c55b03f88c73b85ed1 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 19 Sep 2011 21:31:10 +0100 Subject: [PATCH] Game installer launches game with data directory for Windows (AppData) --- includes/defines.h | 2 ++ src/misc.c | 80 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 69 insertions(+), 13 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index 1d0889cc9..693960fe7 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -22,6 +22,8 @@ #define LOCAL_LUA_DIR "Lua" +#define APPDATA_SUBDIR "\\HardWIRED" + #define THUMB_CACHE_SIZE 256 #ifndef M_PI diff --git a/src/misc.c b/src/misc.c index 8983f1f8c..7004416ac 100644 --- a/src/misc.c +++ b/src/misc.c @@ -12,6 +12,8 @@ #include #include #if defined WIN32 +#include +#include #include #else #include @@ -467,80 +469,132 @@ char * clipboard_pull_text() int register_extension() { #if defined WIN32 + int returnval; LONG rresult; HKEY newkey; char *currentfilename = exe_name(); char *iconname = NULL; char *opencommand = NULL; + char AppDataPath[MAX_PATH]; iconname = malloc(strlen(currentfilename)+6); - opencommand = malloc(strlen(currentfilename)+13); sprintf(iconname, "%s,-102", currentfilename); - sprintf(opencommand, "\"%s\" open \"%%1\"", currentfilename); + + //Create Roaming application data folder + if(!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, AppDataPath))) + { + returnval = 0; + goto finalise; + } + + //Move Game executable into application data folder + //TODO: Implement + + opencommand = malloc(strlen(currentfilename)+53+strlen(AppDataPath)); + if((strlen(AppDataPath)+strlen(APPDATA_SUBDIR "\\Powder Toy"))