How do I detect that a file is open in another application (e.g. Acrobat) and that it can't be modified?

Q: If PDFDoc::Save() is called while the PDF is open in another
application (Adobe Reader, for example), PDFNet throws an exception.

Is there a way to check for this before saving so I can avoid it?
A: The problem is that Acrobat locks the document so that it can't be
modified. To detect this you can try to open the file with 'write
access' mode just before calling PDFDoc.Save(). If the file fails to
open with 'write access' mode it is most likely being locked by
Acrobat or some other app.