如何知道Windows中临时文件夹temp的所在目录

textstar 2000-08-17 07:11:00
加精
我想知道如何用VB中的函数得到系统中存放临时文件的地方。
...全文
621 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lysccd 2000-08-17
  • 打赏
  • 举报
回复
直接用API函数嘛,我发现你们这些VB高手好象对API不是很感冒一样?WHY????
bing71 2000-08-17
  • 打赏
  • 举报
回复
Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" __
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

private function MyTempPath() as string
Dim sT As String
Dim tmp As String
Dim X As Integer

tmp = String$(2048, 32)
X = GetTempPath(255, tmp)
sT = Mid$(tmp, 1, X)
If Right(sT, 1) = "\" Then sT = Left(sT, Len(sT) - 1)
myTempPath = sT
end sub

bing71 2000-08-17
  • 打赏
  • 举报
回复
Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" __
(ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

private function MyTempPath() as string
Dim sT As String
Dim tmp As String
Dim X As Integer

tmp = String$(2048, 32)
X = GetTempPath(255, tmp)
sT = Mid$(tmp, 1, X)
If Right(sT, 1) = "\" Then sT = Left(sT, Len(sT) - 1)
myTempPath = sT
end sub

U皮特U 2000-08-17
  • 打赏
  • 举报
回复
用API函数:GetTempPath
supercow 2000-08-17
  • 打赏
  • 举报
回复
用GetWindowsDirectory函数,
返回的字符串+“\temp”就可以了。
shines77 2000-08-17
  • 打赏
  • 举报
回复
获得Temp目录:

Declare Function GetTempPath Lib "KERNEL32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long

Public Function GetWindowTempPath() As String
Dim Dummy As Long, StrLen As Long, TempPath As String
StrLen = 255
TempPath = String$(StrLen, 0)
Dummy = GetTempPath(StrLen, TempPath)
If Dummy Then
GetWindowTempPath = Left$(TempPath, Dummy)
Else
GetWindowTempPath = ""
End If
End Function

获得Windows目录:

Declare Function GetWindowsDirectory Lib "KERNEL32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Public Function GetWindowsPath() As String
Dim Dummy As Long, StrLen As Long, TempPath As String
StrLen = 255
TempPath = String$(StrLen, 0)
Dummy = GetWindowsDirectory(TempPath, StrLen)
If Dummy Then
GetWindowsPath = Left$(TempPath, Dummy)
Else
GetWindowsPath = ""
End If
End Function

当然,你还可以用iShellLinkA获得所有有关Windows的路径和目录。

To lysccd: 他是VB高手吗???

7,762

社区成员

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

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