怎么获得TEMP文件夹的长路径。

ah_2046 2012-03-13 09:24:02
如题,不知道各位是怎么获得这个长路径的,怎么API,FSO都是短路径呢、。
...全文
145 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
王二.麻子 2012-03-14
  • 打赏
  • 举报
回复

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 Sub Form_Load()
Dim a As String, b As String, c As Long
a = Environ("Temp")
b = Dir(a & "\*.*")
b = a & "\" & b
Dim L As String * 1000
c = GetLongPathName(b, L, 999&)
Debug.Print L
End Sub
ah_2046 2012-03-14
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 chinaboyzyq 的回复:]
VB code

Private Sub Command1_Click()

Set fso = CreateObject("Scripting.FileSystemObject")
Set sh = CreateObject("Shell.Application")
MsgBox sh.NameSpace(fso.GetSpecialFolder(2).Pat……
[/Quote]
猴哥这个是很好,但是有些公司IT很喜欢禁用FSO。
ah_2046 2012-03-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 spt_petrolor 的回复:]
VB code

Option Explicit
Private Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" _
(ByVal lpszShortPath As String, ByVal lpszLongPath As String, ByVal cchBuffer As Long) A……
[/Quote]
对的,就是这个API
chinaboyzyq 2012-03-14
  • 打赏
  • 举报
回复

Private Sub Command1_Click()

Set fso = CreateObject("Scripting.FileSystemObject")
Set sh = CreateObject("Shell.Application")
MsgBox sh.NameSpace(fso.GetSpecialFolder(2).Path).Self.Path
End Sub

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧