There was one other thing I was going to mention to you. Because you close the table right after you find out if you can open it exclusively, the information becomes useless almost immediately. What's to prevent another user from opening the table one millisecond after you've closed it?
Also, if you want to know if you can open all the tables within a DBC exclusively, it's probably easier just to see if you can open the DBC itself exclusively, rather than checking all the tables.