Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing HRESULT constant #490

Open
tajbender opened this issue Oct 14, 2024 · 1 comment
Open

Add missing HRESULT constant #490

tajbender opened this issue Oct 14, 2024 · 1 comment

Comments

@tajbender
Copy link
Contributor

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
Copy link
Contributor Author

tajbender commented Oct 14, 2024

You may https://searchcode.com/?q=0x80070490 give a try.

I've found some naming, e.g. in WIX: https://searchcode.com/file/28621585/src/ext/BalExtension/mba/core/NativeMethods.cs/

internal const int E_NOTFOUND = unchecked((int)0x80070490);

Regards,
tajbender

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant