2009. október 9., péntek
How to assign a system variable to a Session.PrivateDir
Problem/Question/Abstract:
On a terminal server I have a login script, which creates a temporary folder (c:\Temp\OfficeTemp\%username%) for each user that logs in. The system variable name is "OfficeTemp". So how do I assign this system variable to Session.PrivateDir? I tried Session.PrivateDir := 'OfficeTemp'; but this did not work. If I explicitly hardcode to := ''C:\temp\OfficeTemp\darshak' it works, but then I am back to my problem of share violation with multiple database, because all the temp files (all users) get created on that folder.
Answer:
function GetPESEnvironmentValue(pesVarName: string): string;
var
lth: integer;
begin
lth := GetEnvironmentVariable(@pesVarName[1], nil, 0);
if lth > 0 then
begin
SetLength(result, lth);
GetEnvironmentVariable(@pesVarName[1], @result[1], lth);
end
else
result := '';
end;
Session.PrivateDir := GetPESEnvironmentValue('OfficeTemp');
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése