Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Delphi 5: sysutils.GetEnvironmentVariable? (https://www.delphipraxis.net/91390-delphi-5-sysutils-getenvironmentvariable.html)

hincapie 4. Mai 2007 09:59


Delphi 5: sysutils.GetEnvironmentVariable?
 
Hallo,

ich habe hier ein Delphi-Projekt (offenbar D7?) mit folgendem Code-Ausschnitt:
Delphi-Quellcode:
..if fileexists(sysutils.GetEnvironmentVariable('temp')+'\registry_bak.REG') then..
Beim Kompilieren mit D5 erscheint der Fehler 'Undefinierter Bezeichner: GetEnvironmentVariable'. :shock:
In der Hilfe ist auch in der Unit sysutils dazu nichts zu finden.

Meine Frage ist nun, wie kann ich ohne diese Funktion an den benötigten Pfad kommen? :?:

marabu 4. Mai 2007 10:15

Re: Delphi 5: sysutils.GetEnvironmentVariable?
 
Hallo,

du kannst die Windows API Funktion auch selbst kapseln:

Delphi-Quellcode:
function GetEnvVar(const varName: string): string;
var
  nSize: DWORD;
begin
  nSize := GetEnvironmentVariable(PChar(varName), @Result[1], 0);
  SetLength(Result, nSize);
  GetEnvironmentVariable(PChar(varName), @Result[1], nSize);
end;
Grüße vom marabu

hincapie 4. Mai 2007 12:09

Re: Delphi 5: sysutils.GetEnvironmentVariable?
 
Super!!!

Danke, es funktioniert!! :???: :thumb:


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:45 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz