标题: 获取系统的临时目录路径的函数源代码
lonjew
元帅
Rank: 1



UID 73191
精华 1
积分 30615
帖子 14941
威望 3
金币 14931
热心 12
阅读权限 100
注册 2008-1-28
状态 离线
获取系统的临时目录路径的函数源代码

  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

顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-10-8 01:24
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP