On 01/09/14 01:25, Matthew Brush wrote:
On 14-08-31 07:38 AM, Enrico Tröger wrote:
On 30/08/14 03:04, Matthew Brush wrote:
On 14-08-29 07:24 AM, Enrico Tröger wrote:
[snip]
I'd implement this way first, based on your patch, and if we want, we can change to .../Local later anyway if desired.
I think it's probably the easiest solution, with the least code, and most compatibility. If you don't feel like coding it yourself, let me know and I can whip up a (real/working) function to do it. I've been doing a fair bit of Win32 API coding lately so it's fresh on my mind, I
I don't mind, if you like to do it, I'd be happy to test the result :).
Attached is a function that works standalone, it could drop into the previous patch where the untested/working function was. I have only tested on WinXP. If you don't feel like putting it together manually, I can eventually commit it all together properly once I figure out my build system issues.
Tested on Windows 7:
I had to change the function to its multibyte variant:
SHGetFolderPathAndSubDirW
That's the wide character variant, the ASCII one is the A function. You should be able to just use the non-char-specific one as long as we're telling the Win32 API we're using the wide API (I assumed we were since I saw other code in win32.c using wide characters). You need to #define UNICODE or _UNICODE (I always forget) before including "windows.h" to make it work normally/automagically.
Nice to know, thanks. So far we used the wide character variants explicitly in src/win32.c at some places and the default of some functions on the rest. Though at least for those places I wrote, there was no particular reason apart from getting it to work.
Attached is the header I always use to wrap up the Win32 API include/defining weirdness that seems to "just work" with Unicode without any fuss.
Maybe we can incorporate this into Geany src/win32.c at some point but probably in a separate step, this would get too big for this change I guess.
Otherwise it spat out compiler warnings and the resulting config directory was:
㩃啜敳獲敜牮捩屯灁䑰瑡屡潒浡湩屧g旄
:).
Additionally, I had to add the flag CSIDL_FLAG_CREATE so that the ...\Roaming\geany folder is created initially if it doesn't exist yet. Without that flag, SHGetFolderPathAndSubDirW() would fail if the folder doesn't exist.
That should be fine I would think. I just assumed other Geany code dealt with creating it.
Geany would create it later but without the CSIDL_FLAG_CREATE the SHGetFolderPathAndSubDirW() would error out if the directory doesn't exit and so Geany wouldn't continue.
Regards, Enrico