Shi*_*h11 9 delphi directory delphi-7
我正在使用Delphi 7,我想找出我的../所有用户/文档目录的路径.
我遇到了以下代码
uses shlobj, ...
function GetMyDocuments: string;
var
r: Bool;
path: array[0..Max_Path] of Char;
begin
r := ShGetSpecialFolderPath(0, path, CSIDL_Personal, False) ;
if not r then
raise Exception.Create('Could not find MyDocuments folder location.') ;
Result := Path;
end;
Run Code Online (Sandbox Code Playgroud)
它工作正常,但它不支持CSIDL_COMMON_DOCUMENTS返回所需的路径.
此外,根据MS CSIDL不应再使用KNOWNFOLDERID.
我确实需要在多个操作系统(仅限Windows)上运行此应用程序.
我怎样才能做到这一点 ?
感谢帮助:)
在我看来,调用SHGetSpecialFolderPath传球并没有错CSIDL_COMMON_DOCUMENTS.如果您需要支持XP,则无法使用已知的文件夹ID.您可以编写在Vista及更高版本上使用已知文件夹ID的代码,并在早期系统上回退到CSIDL.但为什么要这么麻烦?MS为你做了这件事SHGetSpecialFolderPath.