custapp.inc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2003 by the Free Pascal development team
  5. Linux version of custom app object routines.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. function GetEnvironmentStrings : pchar; external 'kernel32' name 'GetEnvironmentStringsA';
  13. function FreeEnvironmentStrings(p : pchar) : longbool; external 'kernel32' name 'FreeEnvironmentStringsA';
  14. Procedure SysGetEnvironmentList(List : TStrings;NamesOnly : Boolean);
  15. var
  16. s : string;
  17. i,l : longint;
  18. hp,p : pchar;
  19. begin
  20. p:=GetEnvironmentStrings;
  21. hp:=p;
  22. while hp^<>#0 do
  23. begin
  24. s:=strpas(hp);
  25. l:=Length(s);
  26. If NamesOnly then
  27. begin
  28. I:=pos('=',s);
  29. If (I>0) then
  30. S:=Copy(S,1,I-1);
  31. end;
  32. List.Add(S);
  33. hp:=hp+l+1;
  34. end;
  35. FreeEnvironmentStrings(p);
  36. end;