Archive: System::Call 'kernel32::GetTempPath...


System::Call 'kernel32::GetTempPath...
Hi,

I try to determine the temp path with the function GetTemPath of kernel32.dll (OS: Windows2000).

Eg.:
SetOutPath $SYSDIR
StrCpy $0 ${NSIS_MAX_STRLEN}
System::Call 'kernel32::GetTempPath(*i, t) i (r0, .r1) .r2'
MessageBox MB_OK "$0:$1:$2"

I get: 1024::error

What could be wrong?

THX:


1. There two functions A(scii) and W (Unicode). You need first.
2. Why you are using *i (pointer to int)? May be there is wrong tip in documentation somewhere?

System::Call 'kernel32::GetTempPathA(i ${NSIS_MAX_STRLEN}, t .r1) i .r2'


Why not use $TEMP?


brainsucker,
Thanks for the help. It works well with GetTempPathA.

Lobo Lunar,
I tried to use $TEMP, but realised that in Windows there are two TEMP variables defined. One for the current user (User variables) and one among the 'System variables'. I tried to get the second one. $TEMP returns the first one. After brainsucker's help it turned out that GetTempPathA returns the User variable TEMP as well. Finally
ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" TEMP
solved the problem, which returns the Sytem variable temp from the registry.


and if you script this:


SetShellVarContext "all"
MessageBox MB_OK $TEMP

SetShellVarContext works fine eg. with $DESKTOP, $STARTMENU, $SMPROGRAMS, SMSTARTUP or $QUICKLAUNCH
$TEMP returns the current user's TEMP variable with SetShellVarContext "all" as well.
Anyway, good idea with the above mentioned vars.