If I read or write to a file and receive a 33 or 32 error, I would like to log a message containing the name of the other process(es) that have the file opened. There must be a Win32 API I could use to get this info. Process Explorer displays it. Of course, Process Explorer also has info about all processes in memory. I'd prefer to find the culprit without interrogating all processes.
You can find the Winfile file in the \%systemroot%\system32 directory. Browse to the file you want (even across a network share). Press Alt+Enter to view the file's properties. Click Open by to determine who has the file open.
Alternatively referred to as the Windows API and WinAPI, Win32 is the main set of Microsoft Windows APIs used for developing 32-bit applications. These APIs are responsible for functions in the following categories: Administration and Management - Install, configure, and service applications or systems.
Win32 APIs exist for many features and technologies in Windows 10, including core user interface and windowing APIs, audio and graphics, and networking.
The Handle program from SysInternals does this as well, but I'm not sure how. I don't think there is a single documented API to do this. I think you have to iterate over the processes, enumerate each of the handles in the process, and then determine the filename associated with that handle.
As of Windows Vista, the Restart Manager can be used to determine which process(es) have a file open.
This page has sample code: https://devblogs.microsoft.com/oldnewthing/20120217-00/?p=8283
From that page, the steps (for the sample code) are the following:
Here is the documentation for the Restart Manager: https://learn.microsoft.com/en-us/windows/win32/rstmgr/restart-manager-portal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With