Closed NilsHoyer closed 2 months ago
I'm not sure what you're asking, but the HRESULT struct has many of the values and can be extended. It will convert back and forth to exceptions, do reverse lookups on the values, and provide system messages in ToString
's output.
If I have an exception with a HResult of 0x80004005 I would be happy to identify inside my code by using E_FAIL instead of writing 0x80004005.
And I would like to show an error message to my users, which enclosed "E_FAIL", since this is easier to identify than the integer value.
Many of those HRESULT definitions are included (e.g. S_OK, E_FAIL, E_INVALID_ARG, etc.) and can be used like:
HRESULT SomeFunc()
{
// do something
return HRESULT.E_FAIL;
}
HRESULT.ToString
will do a reverse lookup on those constants to provide the constant's name as a string.
Thank you very much. This exactly is what I looked for.
hresult.info reports to have 17242 errors in his database.
The errors I have to handle, you don't support.
If I ask hresult.info about all of their codes, would you interest to implement them into your code?
You bet! Vanara also allows the HRESULT codes to be extended. This is done as you add different libraries from Vanara to your code base. I can use that same model for the codes you need.
I wasn't able to contact somebody on hresult.info. But I crawled their pages and wrote the codes into a file for you: https://www.file-upload.net/en/download-15384040/HRESULT.Values.cs.html
I'm unsure, how to handle HResult = 0x801882C0: https://www.hresult.info/FACILITY_WINDOWS_CE/0x801882C0
The identifier has a space. I believe there are two identifiers for the same HResult code?
I coded this on this way (with the same HResult codes):
/// <summary>Base for CAPAPI errors.</summary>
public const int CABAPI_ERR_BASE = 0x801882C0;
/// <summary>Base for BTS errors.</summary>
public const int BTS_ERR_BASE = 0x801882C0;
Until now, I didn't try to verify, if there is any code in your file, which hresult.info doesn't list. If you take my file, maybe there will some user of it, who gets problems. Additionally, I didn't try to find further codes with the pinvoke.net page, I mentioned. Maybe I will check this too within the next days.
Wow. Thank you.
There are about 650 HResult codes inside your code, I didn't apply until now.
Unfortunately, there are also some double codes in my file.
Maybe I will handle this...
Now, I tried to use all codes from you, from hresult.info and from pinvoke.net together: https://easyupload.io/l9onb0
Some codes had different descriptions (
Some names are doubled, since I found them with different values. They are still inside the .cs file, so you can't compile this file jet. Unfortunately, currently, I have very rarely time with internet access. So you have two options:
I didn't find names for all facilities. Inside the comments, I wrote a "???" instead of them.
Inside your HRESULT.Values.cs file, I found some values, calculates with the AUDCLNT_ERR, AUDCLNT_SUCCESS and Make properties. I transformed that values to the hexadicimal values.
Inside your HRESULT.cs file, I found this line: private const uint facilityMask = 0x7FF0000; I believe, they should be corrected to this one (one "F" more): private const uint facilityMask = 0x7FFF0000;
Please let me know, when you are satisfied with my result, so I can delete all temporary files and projects for generating this file.
I believe, this is the final version: https://easyupload.io/g3625g
It's 30 days available for download.
@NilsHoyer:
I believe, this is the final version: https://easyupload.io/g3625g
It's 30 days available for download.
I can't download this, cause of Trojan / Virus Alert for the Site :atom:
Can't you paste them here? Use triple ` for inserting code.
@dahall BTW, as far as I remember, I use some special WM_*
Message codes somewhere. I'll take a look 🎲
Do you offer the HResult error codes of a COMException with named (Text) codes, like pinvoke.net?
https://www.pinvoke.net/default.aspx/Enums/HRESULT.html