Board index » delphi » Windows temporary directory

Windows temporary directory

Hi!

Does anyone know how to figure out the windows temporary directory.
For example C:\windows\temp\, but probbably it depends on computer to
computer.

Is There any API function on any registry key which gives that
information.

Thanx

 

Re:Windows temporary directory


Quote
On Sun, 05 Apr 1998 22:20:19 GMT, Ci...@cheerful.com (...) wrote:
>Hi!

>Does anyone know how to figure out the windows temporary directory.
>For example C:\windows\temp\, but probbably it depends on computer to
>computer.

>Is There any API function on any registry key which gives that
>information.

>Thanx

for Delphi >= 2.0: GetTempPath (win32 api)
For Delphi 1, you probably would have to look at the DOS environment
(TMP or TEMP variable). There is only GetTempDrive in the api, which
probably gives you "C", which is not much help
hth
David

------------------
David A. Schweizer

iec ProGAMMA, The Netherlands
d.a.schweizer[OK, i don't want any more spam]gamma.rug.nl
guess where the '@' goes ?

Re:Windows temporary directory


Quote
... wrote in message <35280315.8972...@news.arnes.si>...
>Does anyone know how to figure out the windows temporary directory.
>For example C:\windows\temp\, but probbably it depends on computer to
>computer.
>Is There any API function on any registry key which gives that
>information.

GetTempPath (Win32). Also look at GetTempFilename (Win16 / Win32)

--
Zweitze de Vries
zweitze<at>iname<dot>com
When replying, please adjust reply address

Re:Windows temporary directory


In article <35287f37.1062...@news.rug.nl>, David A. Schweizer <d.a.schwe
i...@idontwantspam.gamma.rug.nl> writes

Quote
>On Sun, 05 Apr 1998 22:20:19 GMT, Ci...@cheerful.com (...) wrote:

>>Hi!

>>Does anyone know how to figure out the windows temporary directory.
>>For example C:\windows\temp\, but probbably it depends on computer to
>>computer.

>>Is There any API function on any registry key which gives that
>>information.

>>Thanx
>for Delphi >= 2.0: GetTempPath (win32 api)
>For Delphi 1, you probably would have to look at the DOS environment
>(TMP or TEMP variable). There is only GetTempDrive in the api, which
>probably gives you "C", which is not much help
>hth
>David

For D1, try "GetEnvVar('TEMP')", using the the following function:

{*************************}
{        GetEnvVar        }
{*************************}

{ Function which retrieves the value of a DOS environment variable }

function GetEnvVar(const VarStr: string): string;
var
    PEnv, PVarStr, PEquals: PChar;
begin
    Result := '';

    GetMem(PVarStr, Length(VarStr) + 1);

    try
        { Copy pascal-style string into a null-terminated one }
        StrPCopy(PVarStr, VarStr);

        { Get the DOS environment strings }
        PEnv := GetDOSEnvironment;

        { Step through each individual environment string and look for
          the one which is required }
        while (PEnv^ <> #0) do
        begin
            { Find the position of '=' in the string }
            PEquals := StrScan(PEnv, '=');

            if (PEquals <> nil) then
            begin
                if (StrLIComp(PEnv, PVarStr, (PEquals - PEnv)) = 0) then
                begin
                    { Found it! }
                    Inc(PEquals, 1);
                    Result := StrPas(PEquals);
                    Break;
                end; { end if }

            end; { end if }

            Inc(PEnv, StrLen(PEnv) + 1);
        end; { end while }

    finally
        FreeMem(PVarStr, Length(VarStr) + 1);
    end; { end try }

end;

Hope the above helps.
--
Steve Turner
Leeds, England

Other Threads