2009. október 9., péntek

How to assign a system variable to a Session.PrivateDir


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.


function GetPESEnvironmentValue(pesVarName: string): string;
  lth: integer;
  lth := GetEnvironmentVariable(@pesVarName[1], nil, 0);
  if lth > 0 then
    SetLength(result, lth);
    GetEnvironmentVariable(@pesVarName[1], @result[1], lth);
    result := '';

Session.PrivateDir := GetPESEnvironmentValue('OfficeTemp');

Nincsenek megjegyzések:

Megjegyzés küldése