如何获取系统的临时目录路径?

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 northwolves 的 blog

gettemppath取得的是一个dos名称,当文件名长度大于8时,长文件名格式“c:\documents and settings\administrator\local settings\temp”会显示成“c:\docume~1\admini~1\locals~1\temp”的短文件名格式,如何根据自己需要取得系统临时目录的途径,下面是一个新写的函数,调用两个api 实现,相信许多朋友可能用得到。

option explicit
private declare function getlongpathname lib "kernel32" alias "getlongpathnamea" (byval lpszshortpath as string, byval lpszlongpath as string, byval cchbuffer as long) as long
private declare function gettemppath lib "kernel32" alias "gettemppatha" (byval nbufferlength as long, byval lpbuffer as string) as long


sub gettempfolder(optional byval showlong as boolean = true)
   
    dim longname as string, shortname as string
   
    shortname = space(256)
    gettemppath len(shortname), shortname
 
    longname = space(1024)
    getlongpathname shortname, longname, len(longname)

 

     msgbox "tempfolder : " & iif(showlong = true, longname, shortname)
 
 end sub

private sub command1_click()
 gettempfolder '长文件名
 gettempfolder false '短文件名
end sub

本文关键:如何获取系统的临时目录路径?
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top