您的位置:程序门 -> delphi -> windows sdk/api



vista下如何正确获得系统特殊目录【shgetspecialfolderlocation是不行的】


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


vista下如何正确获得系统特殊目录【shgetspecialfolderlocation是不行的】[已结贴,结贴人:tomore_wanqing]
发表于:2008-02-25 10:46:53 楼主
function   getspecialfolderdir(const   folderid:   integer):   string;
var
pidl:   pitemidlist;
buffer:   array[0..255]   of   char;
begin
    //取指定的文件夹项目表
    shgetspecialfolderlocation(application.handle,   folderid,   pidl);
    shgetpathfromidlist(pidl,   buffer);   //转换成文件系统的路径
    result   :=   strpas(buffer);
end;
调用:
path   :=   getspecialfolderdir(35)+'\mysoftware\';
在xp下面是得到如下结果
path=c:\documents   and   settings\all   users\application   data\mysoftware\
但在vistra下面得到的结果是这样的
path=c:\programdata\mysoftware\
看啦下msdn   发现shgetspecialfolderlocation函数只能支持不支持vistra,郁闷哦!
这是msdn的解释

function   information

minimum   dll   version   shell32.dll   version   4.0   or   later  
custom   implementation   no  
header   shlobj.h  
import   library   shell32.lib  
minimum   operating   systems   windows   nt   4.0,   windows   95  

故在此请教高人,如何解决!


2008-02-25
发表于:2008-02-25 11:07:221楼 得分:10
没用vista顶顶
发表于:2008-02-25 11:14:532楼 得分:20
很抱歉的告诉你,你认为是bug,但是的确那个就是vista上面正确的路径。

vista和xp的特殊目录的确差别很大,所以仔细研究一下吧。
发表于:2008-02-25 11:23:243楼 得分:0
我的天啦!要是想取道c:\documents       and       settings\all       users\application       data\mysoftware\   在vista这么办呢?有解决方案吗?
发表于:2008-02-25 11:47:004楼 得分:10
不知道,帮顶
发表于:2008-02-25 12:43:065楼 得分:20
vista没有documents   and   settings这个文件夹,所有用户共用应用软件信息的文件夹就是c:\programdata\

lz的要求有点叫人难以理解。
发表于:2008-02-25 13:44:286楼 得分:10
或者说得好理解一点,vista更改了特殊文件夹位置的映射关系,

同样是id为35的特殊文件夹,在xp上面被映射为
c:\documents   and   settings\all   users\application   data\

但是在vista上面,这个映射被改为
c:\programdata

发表于:2008-02-25 13:49:297楼 得分:10
刚用vista   看看.
发表于:2008-02-25 15:45:008楼 得分:0
ok!明白啦!我需想是我的安装包打报有问题,真是郁闷呀!全是脚本!天啦!要慢慢研究啦!^_^!!!!!!!!!!开始散分啦!^_^


快速检索

最新资讯
热门点击