private static RM_PROCESS_INFO[] GetProcessInfoList(RmSafeHandle handle) { uint lpdwRebootReasons = 0; uint pnProcInfo = 0; int status = RmGetList(handle, out uint pnProcInfoNeeded, ref pnProcInfo, null, ref lpdwRebootReasons); if (status != ERROR_MORE_DATA && status != 0) { throw new Win32Exception(status); } RM_PROCESS_INFO[] processInfo = new RM_PROCESS_INFO[pnProcInfoNeeded]; pnProcInfo = pnProcInfoNeeded; status = RmGetList(handle, out _, ref pnProcInfo, processInfo, ref lpdwRebootReasons); if (status != 0) { throw new Win32Exception(status); } return(processInfo); }
static extern int RmStartSession(out RmSafeHandle pSessionHandle, int dwSessionFlags, string strSessionKey);
static extern int RmGetList(RmSafeHandle dwSessionHandle, out uint pnProcInfoNeeded, ref uint pnProcInfo, [In, Out] RM_PROCESS_INFO[] rgAffectedApps, ref uint lpdwRebootReasons);
static extern int RmRegisterResources(RmSafeHandle pSessionHandle, uint nFiles, string[] rgsFilenames, uint nApplications, RM_UNIQUE_PROCESS[] rgApplications, uint nServices, string[] rgsServiceNames);