Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Powerbuilder 11.5,如果特定的 excel 文件已经在 excel 中打开,我想向用户弹出错误消息。请让我知道评论以找到它。
一种简单的方法是尝试FileOpen()使用LockReadWrite!文件锁定(独占模式)打开文件:
FileOpen()
LockReadWrite!
-1
FileClose()
这种检查的缺陷是它只是尝试对文件进行独占访问,如果打开失败,文件可能已经打开,但您无法分辨是哪个进程/应用程序。
困难的方法是枚举进程及其文件句柄,以检查是否有一个指向您正在检查的文件。并非不可能,但使用 PowerBuilder 更难做到。