private uint EnumSources(StringBuilder sourceBuf, uint i, NativeMethods.SourceType sourceType) { int enumType = (this.installation.InstallationType | (int)sourceType); uint sourceBufSize = (uint)sourceBuf.Capacity; uint ret = NativeMethods.MsiSourceListEnumSources( this.installation.InstallationCode, this.installation.UserSid, this.installation.Context, (uint)enumType, i, sourceBuf, ref sourceBufSize); if (ret == (uint)NativeMethods.Error.MORE_DATA) { sourceBuf.Capacity = (int)++sourceBufSize; ret = NativeMethods.MsiSourceListEnumSources( this.installation.InstallationCode, this.installation.UserSid, this.installation.Context, (uint)enumType, i, sourceBuf, ref sourceBufSize); } return(ret); }
private void ClearSourceType(NativeMethods.SourceType type) { uint ret = NativeMethods.MsiSourceListClearAllEx( this.installation.InstallationCode, this.installation.UserSid, this.installation.Context, (uint)type | (uint)this.installation.InstallationType); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } }
/// <summary> /// Adds or reorders a network or URL source for the product or patch. /// </summary> /// <param name="item">Path to the source to be added. This parameter is /// expected to contain only the path without the filename.</param> /// <param name="index">Specifies the priority order in which the source /// will be inserted</param> /// <remarks><p> /// If this method is called with a new source and <paramref name="index"/> /// is set to 0, the installer adds the source to the end of the source list. /// </p><p> /// If this method is called with a source already existing in the source /// list and <paramref name="index"/> is set to 0, the installer retains the /// source's existing index. /// </p><p> /// If the method is called with an existing source in the source list /// and <paramref name="index"/> is set to a non-zero value, the source is /// removed from its current location in the list and inserted at the position /// specified by Index, before any source that already exists at that position. /// </p><p> /// If the method is called with a new source and Index is set to a /// non-zero value, the source is inserted at the position specified by /// <paramref name="index"/>, before any source that already exists at /// that position. The index value for all sources in the list after the /// index specified by Index are updated to ensure unique index values and /// the pre-existing order is guaranteed to remain unchanged. /// </p><p> /// If <paramref name="index"/> is greater than the number of sources /// in the list, the source is placed at the end of the list with an index /// value one larger than any existing source. /// </p><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msisourcelistaddsourceex.asp">MsiSourceListAddSourceEx</a> /// </p></remarks> public void Insert(string item, int index) { if (item == null) { throw new ArgumentNullException("item"); } NativeMethods.SourceType type = item.Contains("://") ? NativeMethods.SourceType.Url : NativeMethods.SourceType.Network; uint ret = NativeMethods.MsiSourceListAddSourceEx( this.installation.InstallationCode, this.installation.UserSid, this.installation.Context, (uint)type | (uint)this.installation.InstallationType, item, (uint)index); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } }
/// <summary> /// Removes a network or URL source. /// </summary> /// <remarks><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msisourcelistclearsource.asp">MsiSourceListClearSource</a> /// </p></remarks> public bool Remove(string item) { if (String.IsNullOrEmpty(item)) { throw new ArgumentNullException("item"); } NativeMethods.SourceType type = item.Contains("://") ? NativeMethods.SourceType.Url : NativeMethods.SourceType.Network; uint ret = NativeMethods.MsiSourceListClearSource( this.installation.InstallationCode, this.installation.UserSid, this.installation.Context, (uint)type | (uint)this.installation.InstallationType, item); if (ret != 0) { // TODO: Figure out when to return false. throw InstallerException.ExceptionFromReturnCode(ret); } return(true); }