fjfjfjfjfjfj

[InstallShield]FindAllFiles与SetFileInfo配合实现文件加多文件属性设置

很荣幸,InstallShield提供了函数SetFileInfo,但是很遗憾该还属却不支持文件夹整体修改。

首先试验用WinApi SetFileAttributsA,失败了!不知原因何故!

没有办法只能用InstallShield提供的FindAllFiles与SetFileInfo配合实现修改整个文件夹的文件属性设置。

 

function SetFileArrtibuteNomal(svDir)

  string svResult, svFileSpec, svMatchingFileName;

  int      nResult, nvResult;

begin

  svFileSpec=“*.*”;

  svMatchingFileName = "";

  //find the first file form folder

  nResult = Find AllFiles(svDir, svFileSpec, svMatchingFileName, RESET);

  while(nResult = 0)

    if(GetFileInfo(svMatchingFileName, FILE_ATTRIBUTE, nvResult, svResult) = 0) then

      if(nvResult = FILE_ATTR_NOMAL) then

        //the file is nomal;

      else

        if(FILE_ATTR_HIDDEN & nvResult ) then

          //the file is hidden;

          SetFileInfo(svMatchingFileName, FILE_ATTRIBUTE, FILE_ATTER_NOMAL,"");

        endif; 

        if(FILE_ATTR_READONLY & nvResult ) then 

          //the file is read-only;

          SetFileInfo(svMatchingFileName, FILE_ATTRIBUTE, FILE_ATTER_NOMAL,"");

        endif;

      endif;

    endif;

    //find the next file

    nResult = Find AllFiles(svDir, svFileSpec, svMatchingFileName, CONTINUE);  

  endwhile;

  //release the files

  nResult = Find AllFiles(svDir, svFileSpec, svMatchingFileName, CANCEL);  

end;

 

 

以上代码在InstallShield2009测试通过!

posted on 2010-12-07 15:55  撬棍  阅读(692)  评论(0编辑  收藏  举报

导航