Page 1 of 1

mtmp:=Getenv("TEMP")

Posted: Fri Jun 30, 2006 11:57 am
by jacquet philippe
I use this function and do'nt receive the same result.
===
Under win2000 it return the temp directory of the user c:\documents and setting .....

Under Win XP it return c:\windows\temp

How to return the temp directory of the user with WinXp .

Re: mtmp:=Getenv("TEMP")

Posted: Fri Jun 30, 2006 2:55 pm
by Enrico Maria Giordano
It depends on local settings. In my XP I get c:\documents and setting ... It is the default setting.

EMG

Posted: Fri Jun 30, 2006 7:35 pm
by jacquet philippe
With Fivewin and clipper , it return c:\windows\temp

With xharbour and fivewin, it return c:\documents and setting ....


Strong ! 16 and 32 bit !!

Posted: Fri Jun 30, 2006 9:35 pm
by Enrico Maria Giordano
Ops, I was not aware to be in the Fivewin for Clipper forum. Yes, I tried with FWH. With Clipper I get c:\windows\temp.

EMG

Posted: Sun Jul 02, 2006 3:51 pm
by Mdandrea
Or you can use the following API call to get the windows temp folder
function get_temp()
local tbuffer:=space(256)

gettemppath(256,@tbuffer)
tbuffer := LEFT(tbuffer,AT(CHR(0),tbuffer)-1)
return(tbuffer)

DLL32 Function GetTempPath( bufferlen as LONG, tbuffer AS LPSTR) AS LONG ;
PASCAL FROM "GetTempPathA" LIB "kernel32.dll"

Posted: Tue Jul 04, 2006 8:04 am
by jacquet philippe
I have the same result with the api,
it return windows\temp and not the user tem path .

??

Posted: Tue Jul 04, 2006 7:01 pm
by Antonio Linares
Philippe,

It is a Windows issue. Under 16 bits GetEnv( "TEMP" ) returns "c:\windows\temp" and under 32 bits GetEnv( "TEMP" ) return "c:\documents and settings\<username>\...\temp"

Even if you try it this way, you get the different results:

Code: Select all

#include "FiveWin.ch"

function Main()

   local cValue := Space( 256 )

   MsgInfo( GetEnv( "TEMP" ) )
   
   GetEnvironmentVariable( "TEMP", cValue, Len( cValue ) )
   
   MsgInfo( cValue )
   
return nil 

DLL32 FUNCTION GetEnvironmentVariable( cName AS LPSTR, cValue AS LPSTR, nLen AS LONG ) ;
   AS LONG PASCAL FROM "GetEnvironmentVariableA" LIB "kernel32.dll"  

Posted: Wed Jul 05, 2006 5:42 pm
by Mdandrea
jacquet philippe wrote:I have the same result with the api,
it return windows\temp and not the user tem path .

??
That's strange under Win 2000 i get the user temp path, I am however logged in as an admin of the local machine.