您的位置:程序门 -> vb -> 基础类



请问有没有人写过一个根据目录名称返回pidl的函数?(我不希望用弹出对话框的方式来获得pidl)


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


请问有没有人写过一个根据目录名称返回pidl的函数?(我不希望用弹出对话框的方式来获得pidl)
发表于:2007-06-17 20:01:25 楼主
shbrowseforfolder这个函数可以弹出一个文件夹选择窗而返回pidl,但这不是我所需要的功能。

我希望有这样的函数:
function   getpidlfrompath(byval   spath   as   string   )   as   long  

提供路径名称,然后返回pidl
发表于:2007-06-17 22:43:361楼 得分:0

1.对于special   folder,比较容易。直接用call   shgetspecialfolderlocation(0,   csidl,   lpidl)。
2.对于一般folder,用ilcreatefrompathw。

private   declare   function   ilcreatefrompathw   lib   "shell32 "   (byval   pwszpath   as   long)   as   long
#if   win32_ie   > =   &h500   then
private   declare   sub   ilfree   lib   "shell32 "   (byval   pidl   as   long)
#esle
private   declare   sub   ilfree   lib   "shell32 "   alias   "#155 "   (byval   pidl   as   long)
#end   if
public   function   getpidlfrompath(hwnd   as   long,   spath   as   string)   as   long
      getpidlfrompath   =   ilcreatefrompathw(strptr(spath))
end   function
调用:
pidl   =   getpidlfrompath(me.hwnd,   spath)
。。。
ilfree   pidl
pidl   =   0

不知我理解对不对。敬请参考。
发表于:2007-06-19 11:09:382楼 得分:0
public   enum   csidl
csidl_desktop   =   &h0   '   <desktop>
csidl_internet   =   &h1   '   internet   explorer   (icon   on   desktop)
csidl_programs   =   &h2   '   start   menu\programs
csidl_controls   =   &h3   '   my   computer\control   panel
csidl_printers   =   &h4   '   my   computer\printers
csidl_personal   =   &h5   '   my   documents
csidl_favorites   =   &h6   '   <user   name> \favorites
csidl_startup   =   &h7   '   start   menu\programs\startup
csidl_recent   =   &h8   '   <user   name> \recent
csidl_sendto   =   &h9   '   <user   name> \sendto
csidl_bitbucket   =   &ha   '   <desktop> \recycle   bin
csidl_startmenu   =   &hb   '   <user   name> \start   menu
csidl_mydocuments   =   &hc   '   logical   "my   documents "   desktop   icon
csidl_mymusic   =   &hd   '   "my   music "   folder
csidl_myvideo   =   &he   '   "my   videos "   folder
csidl_desktopdirectory   =   &h10   '   <user   name> \desktop
csidl_drives   =   &h11   '   my   computer
csidl_network   =   &h12   '   network   neighborhood   (my   network   places)
csidl_nethood   =   &h13   '   <user   name> \nethood
csidl_fonts   =   &h14   '   windows\fonts
csidl_templates   =   &h15
csidl_common_startmenu   =   &h16   '   all   users\start   menu
csidl_common_programs   =   &h17   '   all   users\start   menu\programs
csidl_common_startup   =   &h18   '   all   users\startup
csidl_common_desktopdirectory   =   &h19   '   all   users\desktop
csidl_appdata   =   &h1a   '   <user   name> \application   data
csidl_printhood   =   &h1b   '   <user   name> \printhood
csidl_local_appdata   =   &h1c   '   <user   name> \local   settings\applicaiton   data   (non   roaming)
csidl_altstartup   =   &h1d   '   non   localized   startup
csidl_common_altstartup   =   &h1e   '   non   localized   common   startup
csidl_common_favorites   =   &h1f
csidl_internet_cache   =   &h20
csidl_cookies   =   &h21
csidl_history   =   &h22
csidl_common_appdata   =   &h23   '   all   users\application   data
csidl_windows   =   &h24   '   getwindowsdirectory()
csidl_system   =   &h25   '   getsystemdirectory()
csidl_program_files   =   &h26   '   c:\program   files
csidl_mypictures   =   &h27   '   c:\program   files\my   pictures
csidl_profile   =   &h28   '   userprofile
csidl_systemx86   =   &h29   '   x86   system   directory   on   risc
csidl_program_filesx86   =   &h2a   '   x86   c:\program   files   on   risc
csidl_program_files_common   =   &h2b   '   c:\program   files\common
csidl_program_files_commonx86   =   &h2c   '   x86   program   files\common   on   risc
csidl_common_templates   =   &h2d   '   all   users\templates
csidl_common_documents   =   &h2e   '   all   users\documents
csidl_common_admintools   =   &h2f   '   all   users\start   menu\programs\administrative   tools
csidl_admintools   =   &h30   '   <user   name> \start   menu\programs\administrative   tools
csidl_connections   =   &h31   '   network   and   dial-up   connections
csidl_common_music   =   &h35   '   all   users\my   music
csidl_common_pictures   =   &h36   '   all   users\my   pictures
csidl_common_video   =   &h37   '   all   users\my   video
csidl_resources   =   &h38   '   resource   direcotry
csidl_resources_localized   =   &h39   '   localized   resource   direcotry
csidl_common_oem_links   =   &h3a   '   links   to   all   users   oem   specific   apps
csidl_cdburn_area   =   &h3b   '   userprofile\local   settings\application   data\microsoft\cd   burning
csidl_computersnearme   =   &h3d   '   computers   near   me   (computered   from   workgroup   membership)
end   enum

public   enum   csidl_folderpath
shgfp_type_current   =   &h0   '   return   the   folder 's   current   path.
shgfp_type_default   =   &h1   '   return   the   folder 's   default   path.
end   enum

1.对于special   folder,比较容易。直接用call   shgetspecialfolderlocation(0,   csidl,   lpidl)。
2.对于一般folder,用ilcreatefrompathw。

private   declare   function   ilcreatefrompathw   lib   "shell32 "   (byval   pwszpath   as   long)   as   long
#if   win32_ie   > =   &h500   then
private   declare   sub   ilfree   lib   "shell32 "   (byval   pidl   as   long)
#esle
private   declare   sub   ilfree   lib   "shell32 "   alias   "#155 "   (byval   pidl   as   long)
#end   if

private   function   pathtopidl(byval   spath   as   string)   as   long
dim   lret   as   long

lret   =   ilcreatefrompath(strptr(spath))
if   lret   =   0   then
spath   =   strconv(spath,   vbunicode)
lret   =   ilcreatefrompath(spath)
end   if

pathtopidl   =   lret
end   function

调用:
pidl   =   pathtopidl(spath)
。。。
ilfree   pidl
pidl   =   0

不知我理解对不对。敬请参考。
发表于:2007-06-19 11:11:413楼 得分:0
'revised

public   enum   csidl
csidl_desktop   =   &h0   '   <desktop>
csidl_internet   =   &h1   '   internet   explorer   (icon   on   desktop)
csidl_programs   =   &h2   '   start   menu\programs
csidl_controls   =   &h3   '   my   computer\control   panel
csidl_printers   =   &h4   '   my   computer\printers
csidl_personal   =   &h5   '   my   documents
csidl_favorites   =   &h6   '   <user   name> \favorites
csidl_startup   =   &h7   '   start   menu\programs\startup
csidl_recent   =   &h8   '   <user   name> \recent
csidl_sendto   =   &h9   '   <user   name> \sendto
csidl_bitbucket   =   &ha   '   <desktop> \recycle   bin
csidl_startmenu   =   &hb   '   <user   name> \start   menu
csidl_mydocuments   =   &hc   '   logical   "my   documents "   desktop   icon
csidl_mymusic   =   &hd   '   "my   music "   folder
csidl_myvideo   =   &he   '   "my   videos "   folder
csidl_desktopdirectory   =   &h10   '   <user   name> \desktop
csidl_drives   =   &h11   '   my   computer
csidl_network   =   &h12   '   network   neighborhood   (my   network   places)
csidl_nethood   =   &h13   '   <user   name> \nethood
csidl_fonts   =   &h14   '   windows\fonts
csidl_templates   =   &h15
csidl_common_startmenu   =   &h16   '   all   users\start   menu
csidl_common_programs   =   &h17   '   all   users\start   menu\programs
csidl_common_startup   =   &h18   '   all   users\startup
csidl_common_desktopdirectory   =   &h19   '   all   users\desktop
csidl_appdata   =   &h1a   '   <user   name> \application   data
csidl_printhood   =   &h1b   '   <user   name> \printhood
csidl_local_appdata   =   &h1c   '   <user   name> \local   settings\applicaiton   data   (non   roaming)
csidl_altstartup   =   &h1d   '   non   localized   startup
csidl_common_altstartup   =   &h1e   '   non   localized   common   startup
csidl_common_favorites   =   &h1f
csidl_internet_cache   =   &h20
csidl_cookies   =   &h21
csidl_history   =   &h22
csidl_common_appdata   =   &h23   '   all   users\application   data
csidl_windows   =   &h24   '   getwindowsdirectory()
csidl_system   =   &h25   '   getsystemdirectory()
csidl_program_files   =   &h26   '   c:\program   files
csidl_mypictures   =   &h27   '   c:\program   files\my   pictures
csidl_profile   =   &h28   '   userprofile
csidl_systemx86   =   &h29   '   x86   system   directory   on   risc
csidl_program_filesx86   =   &h2a   '   x86   c:\program   files   on   risc
csidl_program_files_common   =   &h2b   '   c:\program   files\common
csidl_program_files_commonx86   =   &h2c   '   x86   program   files\common   on   risc
csidl_common_templates   =   &h2d   '   all   users\templates
csidl_common_documents   =   &h2e   '   all   users\documents
csidl_common_admintools   =   &h2f   '   all   users\start   menu\programs\administrative   tools
csidl_admintools   =   &h30   '   <user   name> \start   menu\programs\administrative   tools
csidl_connections   =   &h31   '   network   and   dial-up   connections
csidl_common_music   =   &h35   '   all   users\my   music
csidl_common_pictures   =   &h36   '   all   users\my   pictures
csidl_common_video   =   &h37   '   all   users\my   video
csidl_resources   =   &h38   '   resource   direcotry
csidl_resources_localized   =   &h39   '   localized   resource   direcotry
csidl_common_oem_links   =   &h3a   '   links   to   all   users   oem   specific   apps
csidl_cdburn_area   =   &h3b   '   userprofile\local   settings\application   data\microsoft\cd   burning
csidl_computersnearme   =   &h3d   '   computers   near   me   (computered   from   workgroup   membership)
end   enum

public   enum   csidl_folderpath
shgfp_type_current   =   &h0   '   return   the   folder 's   current   path.
shgfp_type_default   =   &h1   '   return   the   folder 's   default   path.
end   enum

1.对于special   folder,比较容易。直接用call   shgetspecialfolderlocation(0,   csidl,   lpidl)。
2.对于一般folder,用ilcreatefrompathw。

private   declare   function   ilcreatefrompathw   lib   "shell32 "   (byval   pwszpath   as   long)   as   long
#if   win32_ie   > =   &h500   then
private   declare   sub   ilfree   lib   "shell32 "   (byval   pidl   as   long)
#esle
private   declare   sub   ilfree   lib   "shell32 "   alias   "#155 "   (byval   pidl   as   long)
#end   if

private   function   pathtopidl(byval   spath   as   string)   as   long
dim   lret   as   long

lret   =   ilcreatefrompath(strptr(spath))
if   lret   =   0   then
spath   =   strconv(spath,   vbunicode)
lret   =   ilcreatefrompath(strptr(spath))       'strptr
end   if

pathtopidl   =   lret
end   function

调用:
pidl   =   pathtopidl(spath)
。。。
ilfree   pidl
pidl   =   0

不知我理解对不对。敬请参考。
发表于:2007-06-19 23:30:424楼 得分:0
...............................................


快速检索

最新资讯
热门点击