如何检查Inno Setup预处理器中是否存在目录?

时间:2014-09-09 16:48:16

标签: preprocessor inno-setup

我想做的是:

#define SAMPLE_DOCS_ROOT "C:\SampleDocuments\"
#if CLIENT != ""
  #define SAMPLE_DOCS_CLIENT SAMPLE_DOCS_ROOT + "client\" + CLIENT
  #ifexist SAMPLE_DOCS_CLIENT
    #define SAMPLE_DOCS_PATH SAMPLE_DOCS_CLIENT + "\*"
  #endif
#endif

即使存在SAMPLE_DOCS_CLIENT文件夹,也永远不会定义SAMPLE_DOCS_PATH。

似乎#ifexist ISPP指令不接受绝对或相对目录路径,并且只接受文件路径。有没有办法在编译时检查目录的存在?

1 个答案:

答案 0 :(得分:1)

您需要使用DirExists功能。 #ifexist指令只能用于文件。所以写下这个:

#define SAMPLE_DOCS_ROOT "C:\SampleDocuments\"
#if CLIENT != ""
  #define SAMPLE_DOCS_CLIENT SAMPLE_DOCS_ROOT + "client\" + CLIENT
  #if DirExists(SAMPLE_DOCS_CLIENT)
    #define SAMPLE_DOCS_PATH SAMPLE_DOCS_CLIENT + "\*"
  #endif
#endif