PBDR.COM

About   -   Contact   -   Purchase   -   Search   -   What's New

 
 
Windows Temp Directory
This tip for getting the windows temp directory from within windows was submitted by Daniel Barnes. When you've just got to create some temporary storage files, the window temp directory is the recommended place for shoving them! If you're feeling really good, the best place for this to go would be within the PFE layer probably in n_cst_filesrvwin32.
// Declare this as your Local External Function
FUNCTION ulong GetTempPathA (long nBufferLength, &
   ref string lpBuffer  ) LIBRARY "KERNEL32.DLL"

// Now you write a function somewhere in your app, probably in some global 
// function manager, or perhaps where you store all your .dll calls
// Code for function of_gettempdir(ref_dir) (or what ever you 
// choose to name it!)
constant long  lcl_maxpath = 260
string         ls_tempdir
ulong          lul_retval

// Windows requires padded string
ls_tempdir = Fill('0', lcl_maxpath)

// Call local external function.
lul_retval = THIS.GetTempPatha(lcl_maxpath, ls_tempdir)

// Windows returns length of string returned, so if anything
// greater than zero, then windows returned something useful.
IF lul_retval > 0 THEN
     ref_dir = ls_tempdir
     RETURN SUCCESS
END IF

// Nothing found, or dll call failed.
ref_dir = ''

RETURN FAILURE
 

Top of Page

Legal Notice

Ken Howe 2011