zoukankan      html  css  js  c++  java
  • 如何获取系统的临时目录路径?

    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

  • 相关阅读:
    查询URL字符串参数
    location 对象
    css3 文字特效
    functionDo
    css3 渐变
    [LeetCode][Java]Peeking Iterator
    [LeetCode][JavaScript]Expression Add Operators
    [LeetCode][JavaScript]Different Ways to Add Parentheses
    [LeetCode][JavaScript]Move Zeroes
    [LeetCode][JavaScript]Binary Tree Postorder Traversal
  • 原文地址:https://www.cnblogs.com/fengju/p/6336383.html
Copyright © 2011-2022 走看看