傳統的獲取Windows特殊目錄路徑方法是調用SHGetSpecialFolderPath 函數,比如“我的文檔”, “我的音樂”。
Vista/Win7 多了不少特殊路徑,“下載”(英文版上是 "Downloads" ),“游戲”(英文版上是"Saved Games")等等, 這些目錄是無法用SHGetSpecialFolderPath 獲得的。 需要使用新函數 SHGetKnownFolderPath 。 傳入FOLDERID_Downloads 參數就可以得到下載文件夾的路徑:
SHGetKnownFolderPath(FOLDERID_Downloads, 0, NULL, &szDownloadFolderPath);
參考http://msdn.microsoft.com/en-us/library/dd378457(VS.85).aspx
SHGetKnownFolderPath 只有在Vista及以后版本才有, 所以請使用GetPRocAddress 來調用
新聞熱點
疑難解答