mtmp:=Getenv("TEMP")

Post Reply
jacquet philippe
Posts: 22
Joined: Fri Nov 04, 2005 9:05 pm
Location: LIEGE Belgium

mtmp:=Getenv("TEMP")

Post 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 .
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: mtmp:=Getenv("TEMP")

Post by Enrico Maria Giordano »

It depends on local settings. In my XP I get c:\documents and setting ... It is the default setting.

EMG
jacquet philippe
Posts: 22
Joined: Fri Nov 04, 2005 9:05 pm
Location: LIEGE Belgium

Post 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 !!
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post 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
Mdandrea
Posts: 21
Joined: Wed Nov 23, 2005 12:24 am

Post 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"
jacquet philippe
Posts: 22
Joined: Fri Nov 04, 2005 9:05 pm
Location: LIEGE Belgium

Post by jacquet philippe »

I have the same result with the api,
it return windows\temp and not the user tem path .

??
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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"  
regards, saludos

Antonio Linares
www.fivetechsoft.com
Mdandrea
Posts: 21
Joined: Wed Nov 23, 2005 12:24 am

Post 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.
Post Reply