This is a 'mod-loader' for warzone2100 that I've been working on for my grandson.
I built this on XP, it worked fine. However, testing it on 7, I get an error when clicking on the 'MAP' button (it didn't specify what the error was, just that the '...program has encountered an error...'.
There are two functions that are essentially identical, one opens a browse-dialog for the MOD directories (which works on both XP and 7) and the other opens the browse-dialog for C:\Documents and Settings\user\My Documents\\Warzone 2100 3.1\maps .
In 7, Documents and Settings doesn't exist, it's a symlink that's supposed to provide backward compatibility to programs like mine.
showmods:
//mod manager, add/delete mods, drag-drop
///////////////////////////////////////////////
int showmods(HWND hwndDlg)
{
char path[1024];
char wzpath[1024];
char instruct[1024];
LPITEMIDLIST resultInfo, pathinfo;
BROWSEINFO bi;
char bidisplay[1024];
char bititle[1024] = "Install your MODS to these folders (global works for most):\n";
ULONG sfgao = SFGAO_FILESYSTEM;
wchar_t ws[100];
sprintf(path,"%s\\mods\\global or \\campaign or \\multiplay\n",WZPATH);
sprintf(wzpath,"%s\\mods",WZPATH);
sprintf(instruct,"Open Explorer, browse to your saved *.wz MODS and drag them to campaign, global or multiplay, below.");
strcat(bititle,path);
strcat(bititle,instruct);
swprintf(ws, 100, L"%hs", wzpath);
bi.hwndOwner = hwndDlg;
bi.pidlRoot = NULL;
bi.pszDisplayName = bidisplay;
bi.lpszTitle = bititle;
bi.ulFlags = BIF_RETURNONLYFSDIRS|BIF_NONEWFOLDERBUTTON|BIF_NEWDIALOGSTYLE|BIF_BROWSEINCLUDEFILES;
bi.lpfn = NULL;
SHParseDisplayName(
ws,
NULL,
&pathinfo,
sfgao,
NULL
);
bi.pidlRoot=pathinfo;
resultInfo =SHBrowseForFolder(&bi);
loadcombo(hmodglobal, makepath(MODPATH,WZPATH,GLOBAL));
loadcombo(hmodglobal, makepath(MODPATH,WZPATH,CAMPAIGN));
loadcombo(hmodglobal, makepath(MODPATH,WZPATH,MULTIPLAY));
return 0;
}
showmaps:
//map manager, add/delete maps, drag-drop
///////////////////////////////////////////////
int showmaps(HWND hwndDlg)
{
char path[1024];
char wzpath[1024];
char instruct[1024];
LPITEMIDLIST resultInfo, pathinfo;
BROWSEINFO bi;
char bidisplay[1024];
char bititle[1024] = "Install your MAPS here:\n";
ULONG sfgao = SFGAO_FILESYSTEM;
wchar_t ws[100];
sprintf(wzpath,"C:\\Documents and Settings\\%s\\My Documents\\Warzone 2100 3.1" ,USER);
sprintf( path,"C:\\Documents and Settings\\%s\\My Documents\\Warzone 2100 3.1\\maps\n",USER);
sprintf(instruct,"Open Explorer, browse to your saved *.wz MAPS and drag them to the maps folder, below.");
strcat(bititle,path);
strcat(bititle,instruct);
swprintf(ws, 100, L"%hs", wzpath);
bi.hwndOwner = hwndDlg;
bi.pidlRoot = NULL;
bi.pszDisplayName = bidisplay;
bi.lpszTitle = bititle;
bi.ulFlags = BIF_RETURNONLYFSDIRS|BIF_NONEWFOLDERBUTTON|BIF_NEWDIALOGSTYLE|BIF_BROWSEINCLUDEFILES;
bi.lpfn = NULL;
SHParseDisplayName(
ws,
NULL,
&pathinfo,
sfgao,
NULL
);
bi.pidlRoot=pathinfo;
resultInfo =SHBrowseForFolder(&bi);
return 0;
}
However, comparing the two functions (and knowing they both work as expected on XP), the only significant difference I see are the paths they access ( showmod() works on both XP and & 7, showmaps() works on XP but not on 7).
Now I haven't done any win-programming in years, so I'm behind the curve on a lot of levels, but can you spot any discrepacies that may be a program-related cause for this behavior on win-7?
Thanks, Tony
PS: Unfortunately, the only way to put this through it's paces is to have warzone2100 installed, at least temporarily, in order to exercise the directory-finding functions and generate the required ini file.
Project files are attached.