title: Open word document in readonly mode
body: <p>I'm using automation to open documents in Word. Sometimes I need to open document in Read mode ON: </p>
  
  <pre><code> var
         WordDocument: _Document;
         WA: TWordApplication;  
       begin
         WA := TWordApplication.Create( nil );
         WA.OnQuit := DocumentClose;
         WA.Connect;
         WordDocument := Wa.Documents.Open( FileName, EmptyParam, true {ReadOnly}, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam );
  </code></pre>
  
  <p>But user can off the Read mode in opened document:</p>
  
  <p><a href="https://i.stack.imgur.com/iyiTL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iyiTL.png" alt="enter image description here"></a></p>
  
  <p>How can I handle this in <code>OnQuit</code> event in procedure <code>DocumentClose</code> ?
  In <code>DocumentClose</code> I want to know if document is in read mode or not.</p>
  
  <p>I do not have any solution because I did not have enough experience with it. 
  So, I need your suggestions, advices about it. Sorry for my English and if I have to add more informations, please let me know. Thanks</p>
  
  <p><strong>UPDATE</strong>
  <br>
  I've tried to read protection type, but it's always return the first case. So, when document opening as ReadOnly isn't protected as wdAllowOnlyReading. Some documents can be protected with password, but there is not problem with it. </p>
  
  <pre><code>const 
    wdAllowOnlyReading: Longword = $00000003;
    wdNoProtection:     Longword = $ffffffff;
  var
    ProtectionType: TOleEnum;
  begin
    ProtectionType := WordDocument.ProtectionType;
    case ProtectionType  of
      wdNoProtection : Showmessage('NoProtection');  
      wdAllowOnlyReading: Showmessage('ReadOnly');
    end;
  end;
  </code></pre>