/// <summary> /// Gets information about a specific patch installation. /// </summary> /// <param name="propertyName">The property being retrieved; see remarks for valid properties.</param> /// <returns>The property value, or an empty string if the property is not set for the patch.</returns> /// <exception cref="ArgumentOutOfRangeException">An unknown patch or property was requested</exception> /// <exception cref="InstallerException">The installer configuration data is corrupt</exception> /// <remarks><p> /// Win32 MSI APIs: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msigetpatchinfo.asp">MsiGetPatchInfo</a>, /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msigetpatchinfoex.asp">MsiGetPatchInfoEx</a> /// </p></remarks> public override string this[string propertyName] { get { StringBuilder buf = new StringBuilder(""); uint bufSize = 0; uint ret; if (this.Context == UserContexts.UserManaged || this.Context == UserContexts.UserUnmanaged || this.Context == UserContexts.Machine) { ret = NativeMethods.MsiGetPatchInfoEx( this.PatchCode, this.ProductCode, this.UserSid, this.Context, propertyName, buf, ref bufSize); if (ret == (uint)NativeMethods.Error.MORE_DATA) { buf.Capacity = (int)++bufSize; ret = NativeMethods.MsiGetPatchInfoEx( this.PatchCode, this.ProductCode, this.UserSid, this.Context, propertyName, buf, ref bufSize); } } else { ret = NativeMethods.MsiGetPatchInfo( this.PatchCode, propertyName, buf, ref bufSize); if (ret == (uint)NativeMethods.Error.MORE_DATA) { buf.Capacity = (int)++bufSize; ret = NativeMethods.MsiGetPatchInfo( this.PatchCode, propertyName, buf, ref bufSize); } } if (ret != 0) { return(null); } return(buf.ToString()); } }