Search code examples
environment-variablesinno-setuppascalscript

GetEnvironmentVariable doesnt work in Inno Setup (Delphi)


Hi I'm using Inno Setup (Delphi based) for my installer I am working on. All I want is to put the username in a String: My code:

var
usrname: string;
begin
usrname := GetEnvironmentVariable('USERNAME');
end;

When I'm trying to compile my code, there is allways this error message:

Unknown identifier 'GetEnvironmentVariable'

What am I doing wrong? Im new in delphi so the correct way might be obvious.


Solution

  • The function you are looking for is called GetEnv in Inno Setup, so fix your code e.g. this way:

    var
      UserName: string;
    begin
      UserName := GetEnv('USERNAME');
    end;