Posted at

SHGetSpecialFolderPathにすべてのCSIDL_*を渡した結果をダンプしてみた


テストコード & 実行環境


  • Visual Studio 2017

TEST_METHOD(SHGetSpecialFolderPath_With_All_Ids)

{
auto ids = {
CSIDL_DESKTOP, CSIDL_INTERNET, CSIDL_PROGRAMS, CSIDL_CONTROLS,
CSIDL_PRINTERS, CSIDL_PERSONAL, CSIDL_FAVORITES, CSIDL_STARTUP,
CSIDL_RECENT, CSIDL_SENDTO, CSIDL_BITBUCKET, CSIDL_STARTMENU,
CSIDL_MYDOCUMENTS, CSIDL_MYMUSIC, CSIDL_MYVIDEO, CSIDL_DESKTOPDIRECTORY,
CSIDL_DRIVES, CSIDL_NETWORK, CSIDL_NETHOOD, CSIDL_FONTS, CSIDL_TEMPLATES,
CSIDL_COMMON_STARTMENU, CSIDL_COMMON_PROGRAMS, CSIDL_COMMON_STARTUP,
CSIDL_COMMON_DESKTOPDIRECTORY, CSIDL_APPDATA, CSIDL_PRINTHOOD,
CSIDL_LOCAL_APPDATA, CSIDL_ALTSTARTUP, CSIDL_COMMON_ALTSTARTUP, CSIDL_COMMON_FAVORITES,
CSIDL_INTERNET_CACHE, CSIDL_COOKIES, CSIDL_HISTORY, CSIDL_COMMON_APPDATA, CSIDL_WINDOWS,
CSIDL_SYSTEM, CSIDL_PROGRAM_FILES, CSIDL_MYPICTURES, CSIDL_PROFILE, CSIDL_SYSTEMX86,
CSIDL_PROGRAM_FILESX86, CSIDL_PROGRAM_FILES_COMMON, CSIDL_PROGRAM_FILES_COMMONX86, CSIDL_COMMON_TEMPLATES,
CSIDL_COMMON_DOCUMENTS, CSIDL_COMMON_ADMINTOOLS, CSIDL_ADMINTOOLS, CSIDL_CONNECTIONS,
CSIDL_COMMON_MUSIC, CSIDL_COMMON_PICTURES, CSIDL_COMMON_VIDEO, CSIDL_RESOURCES,
CSIDL_RESOURCES_LOCALIZED, CSIDL_COMMON_OEM_LINKS, CSIDL_CDBURN_AREA, CSIDL_COMPUTERSNEARME
};

for (auto id : ids) {
CStringA path;
SHGetSpecialFolderPathA(NULL, path.GetBufferSetLength(_MAX_PATH), id, 0);
path.ReleaseBuffer();
CStringA fmt;
fmt.Format("0x%04x : %s\r\n", id, path.IsEmpty() ? "empty" : path);
Logger::WriteMessage(fmt);
}
}


出力結果


output.log

0x0000 : D:\ナデラ\Desktop

0x0001 : empty
0x0002 : C:\Users\ナデラ\AppData\Roaming\Microsoft\Windows\Start Menu\Programs
0x0003 : empty
0x0004 : empty
0x0005 : D:\ナデラ\Documents
0x0006 : C:\Users\ナデラ\Favorites
0x0007 : C:\Users\ナデラ\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
0x0008 : C:\Users\ナデラ\AppData\Roaming\Microsoft\Windows\Recent
0x0009 : C:\Users\ナデラ\AppData\Roaming\Microsoft\Windows\SendTo
0x000a : empty
0x000b : C:\Users\ナデラ\AppData\Roaming\Microsoft\Windows\Start Menu
0x0005 : D:\ナデラ\Documents
0x000d : D:\ナデラ\Music
0x000e : D:\ナデラ\Videos
0x0010 : D:\ナデラ\Desktop
0x0011 : empty
0x0012 : empty
0x0013 : C:\Users\ナデラ\AppData\Roaming\Microsoft\Windows\Network Shortcuts
0x0014 : C:\WINDOWS\Fonts
0x0015 : C:\Users\ナデラ\AppData\Roaming\Microsoft\Windows\Templates
0x0016 : C:\ProgramData\Microsoft\Windows\Start Menu
0x0017 : C:\ProgramData\Microsoft\Windows\Start Menu\Programs
0x0018 : C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
0x0019 : C:\Users\Public\Desktop
0x001a : C:\Users\ナデラ\AppData\Roaming
0x001b : C:\Users\ナデラ\AppData\Roaming\Microsoft\Windows\Printer Shortcuts
0x001c : C:\Users\ナデラ\AppData\Local
0x001d : C:\Users\ナデラ\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
0x001e : C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
0x001f : C:\Users\ナデラ\Favorites
0x0020 : C:\Users\ナデラ\AppData\Local\Microsoft\Windows\INetCache
0x0021 : C:\Users\ナデラ\AppData\Local\Microsoft\Windows\INetCookies
0x0022 : C:\Users\ナデラ\AppData\Local\Microsoft\Windows\History
0x0023 : C:\ProgramData
0x0024 : C:\WINDOWS
0x0025 : C:\WINDOWS\system32
0x0026 : C:\Program Files (x86)
0x0027 : D:\ナデラ\Pictures
0x0028 : C:\Users\ナデラ
0x0029 : C:\WINDOWS\SysWOW64
0x002a : C:\Program Files (x86)
0x002b : C:\Program Files (x86)\Common Files
0x002c : C:\Program Files (x86)\Common Files
0x002d : C:\ProgramData\Microsoft\Windows\Templates
0x002e : C:\Users\Public\Documents
0x002f : C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Administrative Tools
0x0030 : C:\Users\ナデラ\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Administrative Tools
0x0031 : empty
0x0035 : C:\Users\Public\Music
0x0036 : C:\Users\Public\Pictures
0x0037 : C:\Users\Public\Videos
0x0038 : C:\WINDOWS\resources
0x0039 : empty
0x003a : empty
0x003b : C:\Users\ナデラ\AppData\Local\Microsoft\Windows\Burn\Burn
0x003d : empty


本当に知りたかったこと

SHGetSpecialFolderPathのリファレンスを見ると、SHGetFolderPath使おうになっているのにSHGetFolderPathを見ると非推奨と書かれて じゃあどうすれば・・・:thinking: となっている部分が知りたいのですが、どなたか情報あればコメントいただけると幸いです!

[SHGetSpecialFolderPath is not supported. Instead, use ShGetFolderPath.]

Deprecated.