public static WriteBool ( Stream fs, byte flag, bool val ) : void | ||
fs | Stream | |
flag | byte | |
val | bool | |
Résultat | void |
public Stream Save() { MemoryStream ms = new MemoryStream(); try { // Write any file-identification data you want to here WriteFiles.WriteHeader(ms, "IUUDFV2"); //number of registry changes WriteFiles.WriteInt(ms, 0x20, RegistryModifications.Count); for (int i = 0; i < RegistryModifications.Count; i++) { RegistryModifications[i].WriteToStream(ms, true); } //Shortcut information foreach (ShortcutInfo si in ShortcutInfos) { si.SaveToStream(ms, true); } //Previous shortcuts that needs to be installed in order to install new shortcuts foreach (string shortcut in PreviousCommonDesktopShortcuts) { WriteFiles.WriteDeprecatedString(ms, 0x30, shortcut); } foreach (string shortcut in PreviousCommonSMenuShortcuts) { WriteFiles.WriteDeprecatedString(ms, 0x31, shortcut); } foreach (string shortcut in PreviousCUserDesktopShortcuts) { WriteFiles.WriteString(ms, 0x36, shortcut); } foreach (string shortcut in PreviousCUserSMenuShortcuts) { WriteFiles.WriteString(ms, 0x37, shortcut); } //number of file infos WriteFiles.WriteInt(ms, 0x21, CountFileInfos()); // write file info for ngening .NET, execution of files, etc. foreach (UpdateFile file in UpdateFiles) { if (file.Execute || file.IsNETAssembly || file.DeleteFile || file.DeltaPatchRelativePath != null || file.RegisterCOMDll != COMRegistration.None) { ms.WriteByte(0x8B);//Beginning of the file information //relative path to file WriteFiles.WriteDeprecatedString(ms, 0x40, file.RelativePath); //execution of files if (file.Execute) { // execute? WriteFiles.WriteBool(ms, 0x41, true); // execute before update? WriteFiles.WriteBool(ms, 0x42, file.ExBeforeUpdate); if (file.WaitForExecution) { WriteFiles.WriteBool(ms, 0x45, file.WaitForExecution); if (file.RollbackOnNonZeroRet) { // we are rolling back on non-zero return code ms.WriteByte(0x8F); // write all the exceptions we're making for rollback codes if (file.RetExceptions != null) { foreach (int except in file.RetExceptions) { WriteFiles.WriteInt(ms, 0x4D, except); } } } } //commandline arguments if (!string.IsNullOrEmpty(file.CommandLineArgs)) { WriteFiles.WriteDeprecatedString(ms, 0x43, file.CommandLineArgs); } if (file.ProcessWindowStyle != System.Diagnostics.ProcessWindowStyle.Normal) { WriteFiles.WriteInt(ms, 0x4A, (int)file.ProcessWindowStyle); } if (file.ElevationType != ElevationType.SameAswyUpdate) { WriteFiles.WriteInt(ms, 0x4E, (int)file.ElevationType); } } //is it a .NET assembly? if (file.IsNETAssembly) { WriteFiles.WriteBool(ms, 0x44, true); // save whether the files is AnyCPU, x86, or x64 WriteFiles.WriteInt(ms, 0x49, (int)file.CPUVersion); // .NET framework is by default 2.0 - only save the framework version if it's .NET 4.0 or unknown if (file.FrameworkVersion != FrameworkVersion.Net2_0) { WriteFiles.WriteInt(ms, 0x4B, (int)file.FrameworkVersion); } } if (file.RegisterCOMDll != COMRegistration.None) { WriteFiles.WriteInt(ms, 0x4C, (int)file.RegisterCOMDll); } //Delta update particulars: if (file.DeleteFile) { WriteFiles.WriteBool(ms, 0x46, true); } else if (file.DeltaPatchRelativePath != null) { WriteFiles.WriteDeprecatedString(ms, 0x47, file.DeltaPatchRelativePath); if (file.NewFileAdler32 != 0) { WriteFiles.WriteLong(ms, 0x48, file.NewFileAdler32); } } ms.WriteByte(0x9B);//End of the file information } } foreach (string folder in FoldersToDelete) { WriteFiles.WriteDeprecatedString(ms, 0x60, folder); } foreach (string service in ServicesToStop) { WriteFiles.WriteString(ms, 0x32, service); } foreach (StartService service in ServicesToStart) { WriteFiles.WriteString(ms, 0x33, service.Name); if (service.Arguments != null) { WriteFiles.WriteInt(ms, 0x34, service.Arguments.Length); foreach (string arg in service.Arguments) { WriteFiles.WriteString(ms, 0x35, arg); } } } // end of file ms.WriteByte(0xFF); // set the pointer to the top of the file ms.Position = 0; } catch (Exception) { ms.Dispose(); throw; } return(ms); }
Stream SaveClientFile() { MemoryStream ms = new MemoryStream(); try { // file-identification data WriteFiles.WriteHeader(ms, "IUCDFV2"); //Company Name WriteFiles.WriteDeprecatedString(ms, 0x01, CompanyName); //Product Name WriteFiles.WriteDeprecatedString(ms, 0x02, ProductName); // GUID if (m_GUID != null) { WriteFiles.WriteString(ms, 0x0A, m_GUID); } //Installed Version WriteFiles.WriteDeprecatedString(ms, 0x03, InstalledVersion); foreach (string site in ServerFileSites) { //Server File Site WriteFiles.WriteDeprecatedString(ms, 0x04, site); } foreach (string site in ClientServerSites) { //Client Server File Site WriteFiles.WriteDeprecatedString(ms, 0x09, site); } //Header image alignment WriteFiles.WriteDeprecatedString(ms, 0x11, HeaderImageAlign.ToString()); //Header text indent WriteFiles.WriteInt(ms, 0x12, HeaderTextIndent); //Header text color if (!string.IsNullOrEmpty(HeaderTextColorName)) { WriteFiles.WriteDeprecatedString(ms, 0x13, HeaderTextColorName); } //Top image filename if (!string.IsNullOrEmpty(TopImageFilename)) { WriteFiles.WriteDeprecatedString(ms, 0x14, TopImageFilename); } //Side image filename if (!string.IsNullOrEmpty(SideImageFilename)) { WriteFiles.WriteDeprecatedString(ms, 0x15, SideImageFilename); } foreach (DictionaryEntry dLang in Languages) { LanguageCulture lang = (LanguageCulture)dLang.Value; //Language culture WriteFiles.WriteDeprecatedString(ms, 0x18, lang.Culture); //Language filename if (!string.IsNullOrEmpty(lang.Filename)) { WriteFiles.WriteDeprecatedString(ms, 0x16, lang.Filename); } } //Hide the header divider if (HideHeaderDivider) { WriteFiles.WriteBool(ms, 0x17, true); } if (CloseOnSuccess) { WriteFiles.WriteBool(ms, 0x19, true); } if (!string.IsNullOrEmpty(CustomWyUpdateTitle)) { WriteFiles.WriteString(ms, 0x1A, CustomWyUpdateTitle); } if (!string.IsNullOrEmpty(PublicSignKey)) { WriteFiles.WriteString(ms, 0x1B, PublicSignKey); } if (!string.IsNullOrEmpty(UpdatePassword)) { WriteFiles.WriteString(ms, 0x1C, UpdatePassword); } ms.WriteByte(0xFF); ms.Position = 0; } catch (Exception) { ms.Dispose(); throw; } return(ms); }
private Stream SaveClientFile() { MemoryStream memoryStream = new MemoryStream(); try { WriteFiles.WriteHeader(memoryStream, "IUCDFV2"); WriteFiles.WriteDeprecatedString(memoryStream, 1, CompanyName); WriteFiles.WriteDeprecatedString(memoryStream, 2, ProductName); if (m_GUID != null) { WriteFiles.WriteString(memoryStream, 10, m_GUID); } WriteFiles.WriteDeprecatedString(memoryStream, 3, InstalledVersion); foreach (string serverFileSite in ServerFileSites) { WriteFiles.WriteDeprecatedString(memoryStream, 4, serverFileSite); } foreach (string clientServerSite in ClientServerSites) { WriteFiles.WriteDeprecatedString(memoryStream, 9, clientServerSite); } WriteFiles.WriteDeprecatedString(memoryStream, 17, HeaderImageAlign.ToString()); WriteFiles.WriteInt(memoryStream, 18, HeaderTextIndent); if (!string.IsNullOrEmpty(HeaderTextColorName)) { WriteFiles.WriteDeprecatedString(memoryStream, 19, HeaderTextColorName); } if (!string.IsNullOrEmpty(TopImageFilename)) { WriteFiles.WriteDeprecatedString(memoryStream, 20, TopImageFilename); } if (!string.IsNullOrEmpty(SideImageFilename)) { WriteFiles.WriteDeprecatedString(memoryStream, 21, SideImageFilename); } foreach (DictionaryEntry language in Languages) { LanguageCulture languageCulture = (LanguageCulture)language.Value; WriteFiles.WriteDeprecatedString(memoryStream, 24, languageCulture.Culture); if (!string.IsNullOrEmpty(languageCulture.Filename)) { WriteFiles.WriteDeprecatedString(memoryStream, 22, languageCulture.Filename); } } if (HideHeaderDivider) { WriteFiles.WriteBool(memoryStream, 23, val: true); } if (CloseOnSuccess) { WriteFiles.WriteBool(memoryStream, 25, val: true); } if (!string.IsNullOrEmpty(CustomWyUpdateTitle)) { WriteFiles.WriteString(memoryStream, 26, CustomWyUpdateTitle); } if (!string.IsNullOrEmpty(PublicSignKey)) { WriteFiles.WriteString(memoryStream, 27, PublicSignKey); } if (!string.IsNullOrEmpty(UpdatePassword)) { WriteFiles.WriteString(memoryStream, 28, UpdatePassword); } memoryStream.WriteByte(byte.MaxValue); memoryStream.Position = 0L; return(memoryStream); } catch (Exception) { memoryStream.Dispose(); throw; } }