Jump to Real's How-to Main page

Generate a unique filename

[function declaration]
FUNCTION integer GetTempFileNameA  &
   (ref string tempdir, ref string prefix, & 
    integer seed, ref string tempfile )&
    LIBRARY "kernel32"

[powerscript]
integer li_rc 
string ls_tempdir = "c:\temp"
string ls_prefixe = "app"
integer li_seed = 0
string ls_filename

ls_filename = space(256)
li_rc = GetTempFileNameA(ls_tempdir, ls_prefixe, li_seed, ls_filename)
IF li_rc = 0 THEN
   MessageBox("Oups", "Error")
ELSE
   MessageBox("Unique filename", ls_tempfile)
END IF

If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]