Starting with version 2003, you can now use a single command to check if the data file or any of its segments is locked. A file is considered 'locked', if it is write protected.
For example, you could place the following code in the On Startup database method:
If (Is data file locked)
ALERT("The data file is locked. Impossible to open database.")