Maybe this can help?
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio /base/gettemppath.asp> Bye, Madruga > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]] On > Behalf Of Tillman, James > Sent: quarta-feira, 28 de Agosto de 2002 11:47 > To: 'Andre Warnier'; Bellenger, Bruno (Paris); perl-win32-users list > Subject: RE: How to determine Windows Temp Folder? > > > I believe it falls back to "c:\windows" (Win9x) or "c:\winnt" > (WinNT) when the TEMP and TMP env vars are not set. (Yes, > really! I'm not kidding. I'm pretty sure I've seen this before) > > On Win2k, I think it falls back to the USERPROFILE env var > before falling back to c:\winnt\ > > So I think you'll always get a valid directory of some kind, > but not necessarily a very desirable one. > > You'll find the API is truly the best way to handle this, > since with Win2k, c:\windows\temp is no longer the default > location for user's temp files, it's actually a temp > directory in their "Documents and Settings" folder. Since > Microsoft uses the API, you can be pretty sure your code > won't blow up in future Windows versions if you use the API, > too. The same cannot be said for ENV vars, which Microsoft > has always hated as much as they hate the command line. Too > "unixy," I guess :-) > > When in Rome... > > jpt > > > -----Original Message----- > > From: Andre Warnier [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, August 28, 2002 5:19 AM > > To: Bellenger, Bruno (Paris); perl-win32-users list > > Subject: RE: How to determine Windows Temp Folder? > > > > > > I bow to the master(s). > > > > Now the question I have is : > > > > If one deletes the Win32 environment variables "TEMP" and > > "TMP", do the > > functions below still work ? > > What is the logic there ? Does WinXX have a notion of > > "temporary directory" > > independently of what ones tells it in "TEMP" ? > > Or are the two necessarily linked ? > > > > > > > > From MS Knowledge Base, hoping it helps the original questioner : > > quote (Article # Q195763) > > > > > > GetTempPath > > The GetTempPath API function allows you to determine the path > > location of a > > system's temporary folder. It takes two parameters: the > > length of a fixed- > > length or pre-initialized string that will contain the path > > name, and the > > string itself. You must use either a fixed-length string, > or a string > > initialized to a length that you believe will be long enough > > to contain the > > path information. This is to guarantee that Visual Basic > > allocates enough > > buffer space for Windows to return the information. > > > > GetTempPath returns the length of the path name measured in > > bytes, or 0 if > > an error occurs. If the return value is greater than the > > buffer size you > > specified, then no path information was written to the string. > > > > The declaration for GetTempPath is provided in the sample below. > > GetTempFileName The GetTempFileName API function is used to > create a > > fully-qualified temporary file name at a given location. > The function > > takes four > > parameters: the string containing the path for the file, a string > > containing a prefix used to start the unique file name, a unique > > number to construct the temp name, and, finally, a fixed-length or > > pre-initialized > > string used to return the fully qualified file name. Both > the path and > > prefix strings are required and cannot be empty. The unique > > number can be 0 > > (NULL), in which case GetTempFileName creates a unique number > > based on the > > current system time. > > > > GetTempFileName returns the unique number used to create the > > file name, or > > returns 0 if an error occurs. > > > > unquote > > > > > > > > André Warnier > > EIS LP > > [EMAIL PROTECTED] > > > > > > Message text written by "Bellenger, Bruno \(Paris\)" > > > > > > > > http://opensource.activestate.com/authors/jand> ubois/Perl/TPC3/fun.html > > <http://opensource.activestate.com/authors/jandubois/Perl/TPC3 > /fun.html> > > also has this slightly improved version from Jan Dubois : > > use strict; > use Win32::API; > > my $GetTempPath = new Win32::API "kernel32", "GetTempPath", > [qw(N P)], 'N'; > > my $path = ' ' x 256; > my $len = $GetTempPath->Call(length $path, $path); > > if ($len == 0) { > print "GetTempPath() failed: $^E\n"; > } > elsif ($len > length $path) { > print "Buffer too small; we need $len bytes\n"; > } > else { > $path = substr($path,0,$len); > print "Temp path is $path\n"; > } > > > _____________________________________________ > Bruno Bellenger > Sr. Network/Systems Administrator < > > > > _______________________________________________ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs