- 按键认证大神
- 728264
- 3501
- 18
- 1898 朵
- 27453 个
- 1717 个
- 82980
- 2011-08-04
|
1#
t
T
发表于 2022-07-23 16:15
|
|只看楼主
方法1: FileSystemObject对象源码:- Function 获取临时目录_fso
- Dim fso
- Set fso = CreateObject("Scripting.FileSystemObject")
- 获取临时目录_fso = fso.GetSpecialFolder(2)
- Set fso = Nothing
- End Function
复制代码 方法2:WScript对象源码:- Function 获取临时目录_wsh1
- Dim wsh,environment
- Set wsh = createobject("WScript.shell")
- Set environment = wsh.environment("process")
- 获取临时目录_wsh1 = environment.item("temp")
- Set environment = Nothing
- Set wsh = Nothing
- End Function
复制代码 方法3:WScript对象源码:- Function 获取临时目录_wsh2
- Dim wsh
- Set wsh = createobject("WScript.shell")
- 获取临时目录_wsh2 = wsh.ExpandEnvironmentStrings("%temp%")
- Set wsh = Nothing
- End Function
复制代码 方法4:Win32 API GetTempPath源码:
- Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
- Function 获取临时目录_api
- Dim len_str
- Buffer = Space(255)
- len_str = GetTempPath(256, Buffer)
- 获取临时目录_api = Left(Buffer, len_str)
- End Function
复制代码 方法5:按键插件源码:调用例子:- TracePrint 获取临时目录_fso()
- TracePrint 获取临时目录_wsh1()
- TracePrint 获取临时目录_wsh2()
- TracePrint 获取临时目录_api()
- TracePrint Plugin.Sys.GetDir(3)
复制代码 调试结果:脚本 我的脚本1.Q ,第1行:C:\Users\UNNAMED\AppData\Local\Temp脚本 我的脚本1.Q ,第2行:C:\Users\UNNAMED\AppData\Local\Temp脚本 我的脚本1.Q ,第3行:C:\Users\UNNAMED\AppData\Local\Temp脚本 我的脚本1.Q ,第4行:C:\Users\UNNAMED\AppData\Local\Temp\脚本 我的脚本1.Q ,第5行:C:\Users\UNNAMED\AppData\Local\Temp\
|