Get temp path via Windows API

Source: Internet
Author: User
Tags chr

Private Const MAX_PATH as Long = 260
Private Declare Function gettemppath Lib "kernel32" Alias "Gettemppatha" (ByVal nSize as Long, ByVal lpbuffer as String) A S Long

Public Function Gettempdir () as String

Dim NSize as Long
Dim Buff as String
Buff = space$ (MAX_PATH)
NSize = Len (Buff)
Call GetTempPath (nSize, Buff)
Gettempdir = trimnull (Buff)
End Function

Private Function trimnull (item as String)

Dim Pos as Integer
' Double check that there was a chr$ (0) in the string
pos = INSTR (item, chr$ (0))
If POS Then
Trimnull = left$ (item, POS-1)
Else
Trimnull = Item
End If
End Function

Private Sub WriteOutput ()

Dim I as Long
Dim level as Long
Level = 0
Dim Child as IXMLDOMNode
' Output as XML
Dim TempPath as String
TempPath = Gettempdir ()
TempPath = TempPath + "Test.xml"
Open TempPath for Output as #1
Print #1, M_batch.xml
Close #1
End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.