欢迎光临
我们一直在努力

如何获取系统的临时目录路径?-.NET教程,数据库应用

建站超值云服务器,限时71元/月

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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何获取系统的临时目录路径?-.NET教程,数据库应用
分享到: 更多 (0)

相关推荐

  • 暂无文章