Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VFP command/variable for Windows TEMP path?

678 views
Skip to first unread message

Bert

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
I could swear that I ran across a command or system variable a few
days ago that returns the path of the designated Windows TEMP
directory, but now I can't seem to find it ( the help index has been
less than useful). Is anyone familiar with this command/variable?
Thanks.

Bert

Wizard Gene

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
Is sys(2023) what your are looking for ??

also see sys(2015) in the help file.


Bert <no_...@thank.you> wrote in message
news:38840b1a...@news.pipeline.com...
>

Bert

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
SYS(2023) gives the temporary directory used by VFP; I'm looking for
the temporary directory used by Windows. SYS(2015) doesn't appear to
be relevant at all -- was that a typo? Thanks anyway.

Bert

Paul Borowicz

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
Bert:

Try this:

DECLARE LONG GetTempPath IN KERNEL32 ;
LONG @lnPathLen, ;
STRING @lcTempPath

LOCAL lcTmpPath,lnSize

lcTmpPath = SPACE(50)
lnSize = 256

=GetTempPath(128,@lcTmpPath)

WAIT WINDOW lcTmpPath

--OR--

WAIT WINDOW GETENV("TEMP")

HTH,

--Paul


Bert <no_...@thank.you> wrote in message
news:38840b1a...@news.pipeline.com...

Rick Bean

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
Bert,
Unless you override VFP's temp directory in your CONFIG.FPW, it will always
use Window's temp directory. So I guess SYS(2023) can give you what you want
at least some of the time <g>.

Rick

"Bert" <no_...@thank.you> wrote in message

news:38844eb8...@news.pipeline.com...


> SYS(2023) gives the temporary directory used by VFP; I'm looking for
> the temporary directory used by Windows. SYS(2015) doesn't appear to
> be relevant at all -- was that a typo? Thanks anyway.
>
> Bert
>
> "Wizard Gene" <gene_...@email.msn.com> wrote:
>
> >Is sys(2023) what your are looking for ??
> >
> >also see sys(2015) in the help file.
> >
> >
> >
> >

John Carter

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
The api function GetTempPath() looks like what you need.

John.

Bert <no_...@thank.you> wrote in message
news:38840b1a...@news.pipeline.com...

Cyrus Welch

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
Does not windows always create an environment variable called TEMP that
points to the temp path? If that is correct (and thats what I have seen)
then GETENV("TEMP") would give it to you.

--
Cy Welch
Senior Programmer/Analyst
MetSYS Inc
"John Carter" <jo...@foxstreet.demon.co.uk> wrote in message
news:948218752.26420.0...@news.demon.co.uk...

John Carter

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
Yes, but the envvar can be wrong and changeable by users etc. The api call
is trivial, so I'd recommend using that.

John.

Cyrus Welch <cyw...@hotmail.com> wrote in message
news:862bn6$i...@chronicle.concentric.net...

Bert

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
I couldn't get the API call to work (lcTempPath was just an empty
string). I'm not sure what's wrong (I'm not very familiar with using
API's), but the GETENV('TEMP') approach appears to work fine. Thanks.

Bert

"Paul Borowicz" <paul_b...@provide.net> wrote:

>Bert:
>
>Try this:
>
>DECLARE LONG GetTempPath IN KERNEL32 ;
>LONG @lnPathLen, ;
>STRING @lcTempPath
>
>LOCAL lcTmpPath,lnSize
>
>lcTmpPath = SPACE(50)
>lnSize = 256
>
>=GetTempPath(128,@lcTmpPath)
>
>WAIT WINDOW lcTmpPath
>
>--OR--
>
>WAIT WINDOW GETENV("TEMP")
>
>HTH,
>
>--Paul
>
>

Bert

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
This seems to do the job. Thanks.

Bert

"Cyrus Welch" <cyw...@hotmail.com> wrote:

>Does not windows always create an environment variable called TEMP that
>points to the temp path? If that is correct (and thats what I have seen)
>then GETENV("TEMP") would give it to you.
>
>--
>Cy Welch
>Senior Programmer/Analyst
>MetSYS Inc
>"John Carter" <jo...@foxstreet.demon.co.uk> wrote in message
>news:948218752.26420.0...@news.demon.co.uk...
>> The api function GetTempPath() looks like what you need.
>>
>> John.
>>

John Carter

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
Maybe I'm being a little overzealous, but the following works:

declare integer GetTempPath in win32api integer, string
lcTempPath=space(100)+chr(0)

?GetTempPath(100,@lcTempPath) && the @ is v. important or you will get empty
string

* remove trailing chr(0)
?left(lcTempPath,at(chr(0),lcTempPath)-1)

if you use getenv(), one day someone will break your code by:

set temp=c:\non_existent_folder

in their autoexec.bat

John.

Bert <no_...@thank.you> wrote in message

news:3887c671...@news.pipeline.com...

Bert

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
Thanks for the heads-up, John (and the code). You seem to imply that
Windows doesn't look at the TEMP variable when deciding what to use as
the temporary directory -- is that correct? Do you know off the top of
your head what happens if someone deletes the temporary directory that
Windows uses -- does Windows recreate it?

Bert

Cyrus Welch

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
They will also break windows since it actually uses that env variable for
its temp path. If you change that variable windows puts its temp files
wherever you point it. Maybe you might want to add code to check it to make
sure its valid, but I believe what you would get from the OS would be the
same as the variable.

--
Cy Welch
Senior Programmer/Analyst
MetSYS Inc
"John Carter" <jo...@foxstreet.demon.co.uk> wrote in message

news:948232015.20260.0...@news.demon.co.uk...

Cyrus Welch

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
I know I have been able to give windows fits by deleting the temp dir. I
also know that windows will use whatever that variable contains as its temp
directory. Lots of other things will be broke if that variable points to an
invalid location than just your program.

--
Cy Welch
Senior Programmer/Analyst
MetSYS Inc

"Bert" <no_...@thank.you> wrote in message

news:3888e0f8...@news.pipeline.com...


> Thanks for the heads-up, John (and the code). You seem to imply that
> Windows doesn't look at the TEMP variable when deciding what to use as
> the temporary directory -- is that correct? Do you know off the top of
> your head what happens if someone deletes the temporary directory that
> Windows uses -- does Windows recreate it?
>
> Bert
>
> "John Carter" <jo...@foxstreet.demon.co.uk> wrote:
>

Cyrus Welch

unread,
Jan 18, 2000, 3:00:00 AM1/18/00
to
On a postscript type idea. VFP would have a problem, since it uses the
windows temp path for its own temp path as well. I have seen lots of things
get broken by that path being invalid.

John Carter

unread,
Jan 19, 2000, 3:00:00 AM1/19/00
to
I would assume it doesn't use the temp envvar (I'm sure its in the registry
somewheres). I would hope that it recreates it, but knowing MS... :-)

I'll try later.

John Carter

unread,
Jan 19, 2000, 3:00:00 AM1/19/00
to
I've just done some tests on my home PC (Win98, VFP5, 4dos6)

The api call and sys(2023) ignore the temp envvar under most circumstances.
They always refer to c:\windows\temp.

Delete the temp folder and both give the vale of getenv("temp").

When the temp emvvar is invalid it uses the current folder for both.

So it looks like the api call is the safest.

John.


Cyrus Welch <cyw...@hotmail.com> wrote in message

news:862pt8$s...@chronicle.concentric.net...


> They will also break windows since it actually uses that env variable for
> its temp path. If you change that variable windows puts its temp files
> wherever you point it. Maybe you might want to add code to check it to
make
> sure its valid, but I believe what you would get from the OS would be the
> same as the variable.
>

> --
> Cy Welch
> Senior Programmer/Analyst
> MetSYS Inc
> "John Carter" <jo...@foxstreet.demon.co.uk> wrote in message

> news:948232015.20260.0...@news.demon.co.uk...

Cyrus Welch

unread,
Jan 20, 2000, 3:00:00 AM1/20/00
to
It does not recreate it. And it DOES use the env variable.

--
Cy Welch
Senior Programmer/Analyst
MetSYS Inc
"John Carter" <jo...@foxstreet.demon.co.uk> wrote in message

news:948308353.9810.0...@news.demon.co.uk...


> I would assume it doesn't use the temp envvar (I'm sure its in the
registry
> somewheres). I would hope that it recreates it, but knowing MS... :-)
>
> I'll try later.
>

> John.
>
> Bert <no_...@thank.you> wrote in message

> news:3888e0f8...@news.pipeline.com...
> > Thanks for the heads-up, John (and the code). You seem to imply that
> > Windows doesn't look at the TEMP variable when deciding what to use as
> > the temporary directory -- is that correct? Do you know off the top of
> > your head what happens if someone deletes the temporary directory that
> > Windows uses -- does Windows recreate it?
> >
> > Bert
> >
> > "John Carter" <jo...@foxstreet.demon.co.uk> wrote:
> >

0 new messages