Was going through the Filezilla source code and came to this line:
int systemFolders[3] = {CSIDL_PERSONAL, CSIDL_DRIVES, CSIDL_NETWORK};
I searched the project and couldn't find these variables being declared as int开发者_StackOverflow社区s.
I looked up CSIDL_PERSONAL and it seems to be some kind of system variable for Windows.
So why are they ints?
Edit: If it's a path variable, why is it a number?
CSIDLs are numerical identifiers (probably #define
s, whose type is int
) used to refer to some particular system folders on Windows.
To get the path/shell location they refer to have to you have to use some shell function, typically SHGetSpecialFolderPath. The CSIDL are used to specify whose special folder you want to get the path; the alternative would be to have a separated function for each special folder, which is cumbersome and quite a waste of code.
It's very important to use such method to retrieve the position of special folders instead of hardcoding them, because the position of many of them can be customized/is different for each user (think e.g. at the Documents folder).
I don't have a Windows box handy right now, but MSDN lists them as integer constants. They are probably macros included in <shlobj.h>
so they would be expanded as integer literals.
精彩评论