Attribute VB_Name = "xGetTempPath関数"
' @(h) xGetTempPath関数.bas                     ver 1.1 ( '98.10.08  )

' @(s)
'  Windowsのテンポラリパスを取得する関数モジュール
'  本モジュールはテスト用コードモジュールです。
'
Option Explicit

Public Const MAX_PATH = 255
Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Attribute GetTempPath.VB_ProcData.VB_Invoke_Func = " \n14"

Sub xGetTempPathのテスト()  'ExcelまたはVisual Basicで実行してください。
Attribute xGetTempPathのテスト.VB_ProcData.VB_Invoke_Func = " \n14"
    MsgBox "(" & xGetTempPath() & ")"
End Sub

' @(f)
'
' 機能      : Windowsのテンポラリパスを取得する関数
'
' 返り値    : Windowsのテンポラリパス
'             リターンに"\"が付く
'
' 引き数    : なし
'
' 機能説明  : Windowsのテンポラリパスを取得する関数
'
' 備考      : 特になし
'
Function xGetTempPath() As String
Attribute xGetTempPath.VB_ProcData.VB_Invoke_Func = " \n14"
    Dim lpBuffer$, nBufferLength&, rcl&
    
    nBufferLength& = MAX_PATH
    lpBuffer$ = String$(MAX_PATH, 0)
    rcl& = GetTempPath(nBufferLength&, lpBuffer$)
    xGetTempPath = Left(lpBuffer$, InStr(lpBuffer$, Chr$(0)) - 1)
End Function