I need to include StyleUtils.inc
and StyleAPI.inc
in my source file, but I don't want to copy the files to my project folder, or reference the files directly, as the contents and location could change on newer versions of Delphi, although I can see the files under C:\Program Files (x86)\Embarcadero\Studio\22.0\source\vcl
.
The BDS
environment variable points to C:\Program Files (x86)\Embarcadero\Studio\22.0
, so I was wanting to include the files as below, but I have tried escaping with $()
, ${}
, %%
, but the variable is not being referenced.
{$I $(BDS)\Source\Vcl\StyleUtils.inc}
CodePudding user response:
No, you cannot use environment variables in {$I}
directive. What you need to do instead is use a relative path in the directive, and then specify the root folder in the project's Search path
configuration, per the documentation:
https://docwiki.embarcadero.com/RADStudio/en/Include_file_(Delphi)
If the filename does not specify a directory path, then, in addition to searching for the file in the same directory as the current module, Delphi searches in the directories specified in the Search path input box on the Delphi Compiler page of the Project > Options dialog box (or in the directories specified in a -I option on the command line compiler).