ezcgi.inc 735 B

12345678910111213141516171819202122232425262728293031323334
  1. Uses Windows;
  2. { Declared EXPLICITLY with Ansistring, so NO mistaking is possible }
  3. {
  4. This function is VERY inefficient, but the downsize would be to
  5. have initialization/finalization code to get/free the environment
  6. settings.
  7. }
  8. Function Getenv (Var EnvVar : AnsiString): AnsiString;
  9. var
  10. s : string;
  11. i : longint;
  12. hp,p : pchar;
  13. begin
  14. getenv:='';
  15. p:=GetEnvironmentStrings;
  16. hp:=p;
  17. while hp^<>#0 do
  18. begin
  19. s:=StrPas(hp);
  20. i:=pos('=',s);
  21. if upcase(copy(s,1,i-1))=upcase(envvar) then
  22. begin
  23. getenv:=copy(s,i+1,length(s)-i);
  24. break;
  25. end;
  26. { next string entry}
  27. hp:=hp+strlen(hp)+1;
  28. end;
  29. FreeEnvironmentStrings(p);
  30. end;