Reputation: 61
I am using Powerbuilder 11.5, I want to popup the error message to the user if the particular excel file is already opened in excel. Please let me know the comment to find that.
Upvotes: 1
Views: 1226
Reputation: 11465
A simple way is to try to open the file with FileOpen()
with LockReadWrite!
file locking (exclusive mode) :
FileOpen()
returns -1
the opening had fail and you can notify the userFileOpen()
returned something else, juste FileClose()
and continue the processThe flaw in this kind of check is that it just try to have exclusive access to the file and if the opening fails the file is probably already opened, but you cannot tell by which process / application.
The hard way would be to enumerate the processes and their files handles to check if one points to the file you are checking. Not impossible, but much more difficult to do with PowerBuilder.
Upvotes: 3