Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

checking to see if pdf file already in use 1

Status
Not open for further replies.

marineman

Programmer
Jul 2, 2010
11
0
0
US
What is the cleanest way to find out if a file (such as a pdf) has already been opened by another program or user?

When I try to open a PDF in my PB application (using adobePDF OLE control) I get an error when PDF file is being viewed by another user already.

Is there a function to check for this? Even if its a kernel.dll type external function - that's okay, I just am unfamiliar with which one.
 
From my short search on the web, it appears that to determine if a file is locked you need to try to open it (which you are doing) and to trap the error.

Matt

"Nature forges everything on the anvil of time"
 
Thank you Matt, In order resolve the problem I needed to explicitly attempt to open the file with the PB function fileopen()with the (default) exclusive rights set. If the file is already open by some other process this function returns -1 otherwise you get a positive integer (handle id) and with that, I can trap the error or go forward with processing the file.

Thanks for helping me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top