private static void ValidateUpdateCaptionArgs(IUpdateCaptionArgs args) { // caption file should exist if (!File.Exists(args.CaptionPath)) { var message = string.Format(Localization.ValidateArgsCaptionFile, args.CaptionPath); throw new IOException(message); } }
// adds user-friendly caption to screensaver private static void InjectCaption(IUpdateCaptionArgs args) { string caption; try { // read caption from file caption = File.ReadAllText(args.CaptionPath, Constants.CaptionEncoding); } catch (Exception ex) { var message = string.Format(Localization.InjectCaptionFileRead, args.CaptionPath, ex.Message); throw new IOException(message, ex); } // convert text to string table data var stringTableRow = PInvoke.GetStringTable(new[] { null, caption }).Single(); // add string table data to screensaver InjectResource(args.OutputPath, (ushort)PInvoke.ResourceType.STRING, stringTableRow.Key, stringTableRow.Value); }