Vanara icon indicating copy to clipboard operation
Vanara copied to clipboard

Add missing HRESULT constant

Open tajbender opened this issue 4 months ago • 1 comments

Is your feature request related to a problem? Please describe.

I found a COM HResult error constant, that isn't present in Vanara

Describe the additions or enhancements you'd like

I've found HResult 0x80070490 which I use in an Application that deals with Shell32 objects using Vanara. The code is used in Vanara itself, as found here:

	/// <summary>Retrieves a data stream corresponding to this theme, starting from a specified part and state.</summary>
	/// <param name="hInst">The SafeLibraryHandle of a loaded styles file.</param>
	/// <param name="partId">Specifies the part to retrieve a stream from.</param>
	/// <param name="stateId">Specifies the state of the part.</param>
	/// <returns>The data stream.</returns>
	public byte[]? GetDiskStream(HINSTANCE hInst, int partId, int stateId)
	{
		var r = GetThemeStream(Handle, partId, stateId, (int)ThemeProperty.TMT_DISKSTREAM, out var bytes, out var bLen, hInst);
		if (r.Succeeded) return bytes.ToByteArray((int)bLen);
		if (r != 0x80070490) throw new InvalidOperationException("Bad GetThemeStream");
		return null;
	}

and here:

	/// <summary>Retrieves a data stream corresponding to this theme, starting from a specified part and state.</summary>
	/// <param name="partId">Specifies the part to retrieve a stream from.</param>
	/// <param name="stateId">Specifies the state of the part.</param>
	/// <returns>The data stream.</returns>
	public byte[]? GetStream(int partId, int stateId)
	{
		var r = GetThemeStream(Handle, partId, stateId, (int)ThemeProperty.TMT_STREAM, out var bytes, out var bLen, HINSTANCE.NULL);
		if (r.Succeeded) return bytes.ToByteArray((int)bLen);
		if (r != 0x80070490) throw new InvalidOperationException("Bad GetThemeStream");
		return null;
	}

Previous work

I've found this HResult by Try & Error. It is fired when, as far as I remember, someone tries to enumerate an empty disk drive.

I've called it HResult_ElementNotFound, but I don't know if this is official naming.

Your thoughts on this?

tajbender avatar Oct 14 '24 08:10 tajbender