Matthew Talbert ransom1982 at gmail.com
Sat Apr 25 23:02:01 MST 2009

On Sun, Apr 26, 2009 at 1:47 AM, Troy A. Griffitts <scribe at crosswire.org> wrote:
> Hey Matthew,
> You recommended using APPDATA to avoid hardcoding "Application Data" in our
> path string, in case it was localized.
> I noticed that we have a bug in the ALLUSERSPROFILE lookup logic where we
> are NOT appending "Application Data/sword" to ALLUSERSPROFILE and I'm not
> sure how to fix it to avoid the localization errors you mentioned. Do you
> have a way to get %ALLUSERSPROFILE%/Application Data/ with a localization
> sensitive methodology?


There is a way to do this, but it's not easy (bad Microsoft). My
recommendation is to leave ALLUSERPROFILE/Application Data as it is
for now, because it works in the greatest number of cases (it should
actually work on localized installs, though it's obviously not
preferred). When the NTFS stuff is fixed, that would be a good time to
do it correctly. An implementation of the correct method is below
(obviously stolen from glib). Without fixing the Unicode/NTFS issue,
there's no guarantee that the correct location will actually be usable
(the same goes for BibleCS's Program Files location).



p = get_special_folder (CSIDL_COMMON_APPDATA);

get_special_folder (int csidl)
  union {
    char c[MAX_PATH+1];
    wchar_t wc[MAX_PATH+1];
  } path;
  BOOL b;
  gchar *retval = NULL;

  hr = SHGetSpecialFolderLocation (NULL, csidl, &pidl);
  if (hr == S_OK)
      if (G_WIN32_HAVE_WIDECHAR_API ())
          b = SHGetPathFromIDListW (pidl, path.wc);
          if (b)
            retval = g_utf16_to_utf8 (path.wc, -1, NULL, NULL, NULL);
          b = SHGetPathFromIDListA (pidl, path.c);
          if (b)
            retval = g_locale_to_utf8 (path.c, -1, NULL, NULL, NULL);
      CoTaskMemFree (pidl);
  return retval;

More information about the sword-devel mailing list