Skip to content

Instantly share code, notes, and snippets.

@kmteam
Created July 6, 2016 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmteam/7ec0e0a9b627c659f59e87d29df27bc6 to your computer and use it in GitHub Desktop.
Save kmteam/7ec0e0a9b627c659f59e87d29df27bc6 to your computer and use it in GitHub Desktop.
Use OpenFiles in Csharp
// NOTE: Require files 'ListOpenedFileDrv_32.sys' and 'OpenFileFinder.dll'
public class OpenFiles {
public enum OF_TYPE {
FILES_ONLY = 1,
MODULES_ONLY = 2,
ALL_TYPES = 3
};
public struct OF_INFO_t {
public uint dwPID;
[MarshalAs(UnmanagedType.LPWStr)]
public String lpFile;
public int hFile;
};
public delegate bool OF_CALLBACK(OF_INFO_t OpenedFileInf0, int uUserContext);
[DllImport("OpenFileFinder.dll")]
public static extern void GetOpenedFiles([In, MarshalAs(UnmanagedType.LPWStr)] string lpPath, OF_TYPE Filter, OF_CALLBACK CallBackProc, int pUserContext);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment