How to check if a folder is a database folder and if it's already open?

Hello,
Can you explain this in more.