Windows TEMP folder (OpenInsight 32-Bit)
At 19 AUG 2004 10:47:06AM Ed Keeman (Netherlands) wrote:
Hi,
We need to know what the path is to the windows TEMP folder in
OI 7.0.1.
The OI GetEnvironmentVariable() example doesn't work.
Steve Smith wrote an Arev function to do the job, and we hope there is an OI equivalent.
bye
At 19 AUG 2004 11:12AM support@sprezzatura.com wrote:
Do you mean this? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/gettemppath.asp
support@sprezzatura.com
The Sprezzatura Group Web Site
World Leaders in all things RevSoft
At 19 AUG 2004 03:37PM Ed Keeman wrote:
Yep that is a good hint !!!
And for everyone who want's to know the rest of the solution:
I've added the line:
LONG STDCALL GetTempPathA(LONG, LPCHAR) AS GetTempPath
to the SYSPROCS*DLL_KERNEL32 record, and build it.
Example prog:
* Declare Function GetTempPath Path=' Length=0 Length=GetTempPath(Length,Path) Path=Space(Length-1) Length=GetTempPath(Length,Path) call Msg(
,'Windows tempfolder is: ':Path) * Thanks Sprezz-guy Ed Keeman </QUOTE> —- === At 19 AUG 2004 03:45PM dsig@sigafoos.org wrote: === <QUOTE>Sprezz guy .. maybe you could talk to a revsoft guy about GetEnvironmentVariable() having this included .. seems like it should be. dsig@sigafoos.org.com onmouseover=window.status=the new revelation technology .. a refreshing change;return(true)" DSig's Radio Free Oregon David Tod Sigafoos ~ SigSolutions </QUOTE> —- === At 19 AUG 2004 07:05PM Pat McNerthney wrote: === <QUOTE>Path=Space(Length-1) Length=GetTempPath(Length,Path) This does not look like a good idea, you are telling the GetTempPath api that you have a buffer of size 'Length', but in reality the size is one byte less. 99.9% of the time you will get away with this, because the string allocated most likely has enough extra allocated for you that it is not a problem. Better would be something like this: Length=GetTempPath(0,
) + 1 +1 for terminating null byte Path=Space(Length) Length=GetTempPath(Length, Path) Path=Path1, Length Pat </QUOTE> —- === At 19 AUG 2004 09:51PM Steve Smith wrote: === <QUOTE>Prototype: KERNEL32 ULONG STDCALL GetEnvironmentVariableA(LPCHAR,LPCHAR,ULONG) And compile: FUNCTION GETENV(env) * env setting=TEMP" eg RUN GETENV('TEMP') declare function GetEnvironmentVariableA mybuffer=STR(char(0),4096) result=GetEnvironmentVariableA(env,mybuffer,4096) return mybuffer1,result </QUOTE> —- === At 20 AUG 2004 06:20AM Ed Keeman wrote: === <QUOTE>Steve, I tried your solution. It didn't work. Have you tested this code? Ed Keeman </QUOTE> —- === At 20 AUG 2004 02:15PM Pat McNerthney wrote: === <QUOTE>First, are you really, really sure there is a TEMP variable? If yes, try using "TEMP":\00\ for the name passed to the call. Pat </QUOTE> —- === At 20 AUG 2004 03:58PM Steve Smith wrote: === <QUOTE>Yes. Although I noticed the API call I used picks up the user's temp document path, not the generic Windows one under \Windows\Temp. Hmm. Is it possible that your machine has been configured (ie paths renamed/removed) to disable spyware threats writing into the user paths under \Documents and Settings\*.* ? </QUOTE> —- === At 20 AUG 2004 04:17PM Ed Keeman wrote: === <QUOTE>Steve, I don't care if the TEMP folder is under the windows folder, or somewhere in the user's profile. For security reasons we want some files (reports.PDF) on the local harddrive. The best place is the windows TEMP folder. With dll-calls I'm not able to retrieve both the environmentstring or a single variable. It just returns null, nothing. The dll-call GetTempPath worked fine. But this function only return the temp folder. For now that's just what I need, but for the future I maybe want to retrieve other environment variables. Ed Keeman </QUOTE> —- === At 20 AUG 2004 09:12PM Steve Smith wrote: === <QUOTE>Ed, Another piece of code I just wrote to address your TEMP= problem. It's a bit kludgy and uses techniques somewhat risky in terms of GPFs, so don't edit the source too much . But does this work for you to return the full environment to OpenInsight under Windows? Steve <code> expendable function getenv2(void) * Returns the environment settings for the current environment. * © 2004 By Steve Smith, State of the Art Systems Pty. Ltd. * All rights reserved. declare subroutine rtlmovememory declare function GetEnvironmentStringsA declare function FreeEnvironmentStringsA i=4097 address=GetEnvironmentStringsA() mybuf=str(char(0),4097) mybuf2=mybuf garbagecollect rtlmovememory(mybuf, address, 4096) retval=FreeEnvironmentStringsA(address) garbagecollect for i=4096 to 2 step -1 if mybufi,1=char(0) and mybufi+1,1=char(0) then envlen=i end next i mybuf2=mybuf1,envlen-1 convert char(0) to @fm in mybuf2 garbagecollect return mybuf2 /* DLL declarations KERNEL32 HANDLE STDCALL GetEnvironmentStringsA() ULONG STDCALL FreeEnvironmentStringsA(ULONG) VOID STDCALL RtlMoveMemory(LPCHAR,LONG,ULONG) */ </code> </QUOTE> —- === At 21 AUG 2004 12:31AM Steve Smith wrote: === <QUOTE>Amendment to above routine - seems to not like reading in all cases (especially on first time login). Try instead: <code> expendable function getenv2(void) * returns the environment memory block for the current process. declare subroutine rtlmovememory declare function GetEnvironmentStringsA declare function FreeEnvironmentStringsA i=4097 address=GetEnvironmentStringsA() mybuf=str(char(0),4097) mybuf2=mybuf retval=0 garbagecollect rtlmovememory(mybuf, address, 2048) retval=FreeEnvironmentStringsA(address) garbagecollect for i=2048 to 2 step -1 if mybufi,1=char(0) and mybufi+1,1=char(0) then envlen=i end next i mybuf2=mybuf1,envlen-1 convert char(0) to @fm in mybuf2 garbagecollect return mybuf2 /* DLL declarations KERNEL32 HANDLE STDCALL GetEnvironmentStringsA() ULONG STDCALL FreeEnvironmentStringsA(ULONG) VOID STDCALL RtlMoveMemory(LPCHAR,LONG,ULONG) */ </code> </QUOTE> —- === At 21 AUG 2004 12:32AM Steve Smith wrote: === <QUOTE>Prototype: KERNEL32 ULONG STDCALL GetEnvironmentVariableA(LPCHAR,LPCHAR,ULONG) And compile: FUNCTION GETENV(env) * env setting=TEMP" eg RUN GETENV('TEMP') declare function GetEnvironmentVariableA mybuffer=STR(char(0),4096) result=GetEnvironmentVariableA(env:char(0),mybuffer,4096) return mybuffer1,result </QUOTE> —- === At 23 AUG 2004 09:21AM Ed Keeman wrote: === <QUOTE>Steve, this works! Thanx! </QUOTE> View this thread on the Works forum...