在做一个办公系统,要对word进行加密,在文件里面打开要密码,而在delphi办公系统启动时自动解密

解决方案 »

  1.   

    procedure OpenWordFile(State,Path: String; WordApplication1: TwordApplication;worddocument:
    Tworddocument);//打开Word函数过程
    var
       itemindex :olevariant;
       filename, confirmconversions, readonly, addtorecentfiles,
       passworddocument, passwordtemplate, revert,
       writepassworddocument, writepasswordtemplate, format, Encoding, Visible: olevariant;
       begin
        WordApplication1.Connect;// 建立连接
          wordApplication1.Visible:=True;
          filename :=path ;                  //文档名 ( 包含路径 )
          confirmconversions := false;       //是否显示文件转换对话框
          if state='false' then readonly:=false
          else
          readonly :=false;                  //是否以只读方式打开文档
          addtorecentfiles := false;         //是否将文件添加到 " 文件 " 菜单底部的最近使用文件列表中
          passworddocument := '';            //打开此文档时所需要的密码
          passwordtemplate := '';            //打开此模板时所需要的密码
          revert := true;                    //如果文档已经 ,是否重新打开文档
          writepassworddocument := '';       //保存对文档更改时所需要的密码
          writepasswordtemplate := '';       //保存对模板进行更改时所需要的密码
          format := wdopenformatdocument;    //打开文档时所需使用的文件转换器
          Encoding:='';                      //所使用的文档代码页
          Visible:= 1;                       //打开文档的窗口是否可见
          wordapplication1.documents.open( filename, confirmconversions,readonly, addtorecentfiles,
    passworddocument, passwordtemplate,revert, writepassworddocument,writepasswordtemplate,
    format ,Encoding, Visible);
          itemindex := 1;
              if state='True' then
                begin
                  WordApplication1.CommandBars.ActiveMenuBar.Set_Enabled(False); //整个菜单工具兰隐藏
                end
              else
                begin
                   WordApplication1.CommandBars.ActiveMenuBar.Set_Enabled(True);
                end;
                WordApplication1.Disconnect;// 断开连接
    end;
    好像有涉及到word 版本问题,一定要用2000的嘛?