如何检查 pdf 文件是否在 中打开并在 c++ 中关闭它

How to check if a pdf file is open in and close it in c++

本文关键字:c++ 是否 何检查 检查 文件 pdf      更新时间:2023-10-16

我想用 c++ 移动到 pdf 文件中的页面。我使用shellExecute,它工作正常。但是,如果之前打开过该文件,则不会转到目标页面。我想检查文件是否已打开并在使用 shellExecute 命令之前将其关闭。我该怎么做,有没有更好的方法?

您可以使用

is_open()

以检查文件是否已打开。我认为你必须包括iostream和/或fstream。不确定。。

也许这个问题会对你有所帮助:问题

使用这些代码行

std::ifstream ifs ("test.pdf");
if (ifs.is_open()) {
  ifs.close();
}