devxlogo

Get the Windows temporary directory (without any API call)

Get the Windows temporary directory (without any API call)

The usual way to determine the Windows’ main directory is based on the GetTempPath API function, which requires that you set up a buffer for the result, and then extract the null-terminated result. However, there is a much simpler approach, that works equally well under Windows 95, 98 and NT. It is based on the fact that either the TMP or TEMP environment variables (or both of them) already holds the path to that directory, so you just need a single line of code:

tempPath = IIf(Environ$("tmp") <> "", Environ$("tmp"), Environ$("temp"))

See also  How HealthStream Learning Center Supports Healthcare Education and Compliance
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist