When I was setting up ZSNES on my new Vista laptop, I was annoyed that it wouldn't save its configuration file if I put ZSNES in C:\Program Files (because Vista blocks writing to the application directory). I've done a little Win32 programming, so I found the code to modify in zpath.c to customize where ZSNES puts its configuration files.
Getting ZSNES compiled to test the changes was something else altogether; but I finally managed to wrangle the ZSNES 1.51 codebase into the Visual Studio IDE and compiled a working executable! (If anyone is interested in the particulars of how I accomplished this, let me know and I'll post a new thread about it)
I modified zpath.c so that it will attempt to create %APPDATA%\ZSNES\ and store the config files there. If it fails, it will revert to the old behavior. This change has the added benefit of enabling each user on a PC to have their own ZSNES configuration.
I have not done anything with the other ZSNES paths yet; I'm considering adding a check for Vista/7 to utilize the "%USERPROFILE%\Saved Games" folder and create a ZSNES folder containing subfolders for IPS files, save states, SRM files, and screenshots. I am also considering making the Game > Load dialog default to My Documents (although keeping the memory of the last folder you loaded from).
Here is a diff of zpath.c that applies my changes, if anyone else is interested:
Code: Select all
--- Documents\zsnes151src.tar\zsnes_1_51\src\zpath.c Mon Jan 15 14:47:53 2007
+++ Documents\Visual Studio 2008\Projects\zsnes2008\zsnes2008\zpath.c Thu Oct 15 12:56:59 2009
@@ -115,11 +115,38 @@
}
#else
-
+#ifdef __WIN32__
+/*
+ Microsoft guidelines prohibit writing data to the application directory; so we create
+ a zsnes folder in the user profile's application data (%APPDATA%) folder. This has the
+ side-effect of allowing each user to have their own zsnes configuration.
+ */
+void cfgpath_ensure(const char *launch_command)
+{
+ ZCfgPath = malloc(PATH_SIZE);
+ if( ZCfgPath )
+ {
+ char appdata[MAX_PATH];
+ ZCfgAlloc = true;
+
+ if( !GetEnvironmentVariable("APPDATA", appdata, MAX_PATH) )
+ strcpy_s(ZCfgPath, PATH_SIZE, ZStartPath);
+ else
+ {
+ strcpy_s(ZCfgPath, PATH_SIZE, appdata);
+ strcat_s(ZCfgPath, PATH_SIZE, "\\zsnes");
+ strcatslash(ZCfgPath);
+ CreateDirectory(ZCfgPath, NULL);
+ }
+ } else {
+ ZCfgPath = ZStartPath;
+ }
+}
+#else
void cfgpath_ensure(const char *launch_command)
{
ZCfgPath = malloc(PATH_SIZE);
if (ZCfgPath)
{
char *p = 0;
ZCfgAlloc = true;
@@ -148,11 +175,12 @@
ZCfgPath = ZStartPath;
}
}
else
{
ZCfgPath = ZStartPath;
}
}
+#endif
#endif