/// <summary> /// Retrieves the name for the parent of the specified process. /// </summary> /// <returns> /// If the specified process had a parent and its information was retrievable a string containing the name is /// returned. Otherwise null. /// </returns> public static string?GetParentName(this WardenProcess?process) { if (process is null) { return(null); } if (!process.HasProcessAssociation) { return(null); } // The process has no parent. if (process.Info !.ParentProcessId <= 0) { return(null); } // The process had a parent but its dead. if (!ProcessNative.IsProcessRunning(process.Info.ParentProcessId)) { return(null); } try { return(ProcessNative.GetParentProcessName(process.Info.ParentProcessId)); } catch { // Nothing to do } return(null); }
/// <summary> /// Parses and properly formats a command-line string. /// </summary> /// <param name="value"></param> /// <param name="processImage"></param> /// <returns></returns> internal static string FormatCommandLine(this string value, string?processImage = null) => ProcessNative.FormatCommandLine(value, processImage);