I've got Microsoft.Management.Infrastructure working in my application, at least as far as the very first sample code:
CimSession.Create(null)
.QueryInstances(@"root\cimv2", "WQL", "SELECT * FROM Win32_OperatingSystem")
.FirstOrDefault().CimInstanceProperties["Version"].Value.ToString();
What I need is to use MMI to determine whether any applications on the local machine have a lock on a specific file (see this question to see why approaches besides MMI aren't working)
I've been reading page after page of documentation on MMI and WQL and CIM and a flock of other TLAs but cannot figure out how to either
1) ask the question "which process has file X open/locked"?
or
2) enumerate all open/locked files so I can look for file X
Important - I need to do this in code (running Process Explorer won't work for me).