HRESULT (a.k.a. SCODE) is one of data types you will see when playing with COM objects.
Although data type is called result handle, it is not handle to anything. While this may seem like nitpicking, there is one very important difference in case of 64-bit systems. This value is always 32 bits in length (UInt32) while true handle would be either 32 or 64 bits (IntPtr).
Another thing that may strike as unexpected is that result of successful operation is not necessarily 0 as you may expect from your Windows API experience. This value has total of seven sub-types but in reality only three are used.
Severity
If only check whether operation was successful is needed, you can just see state of first bit (31) (SEVERITY_SUCCESS or SEVERITY_ERROR). If that bit is cleared, you are fine. In case of trouble, that bit is set:
If you get facility with number less than or equal to 8, you are pretty sure that it originated from Windows. If you have SEVERITY_ERROR and facility value is 0 (FACILITY_NULL), developer was too lazy to assign facility code.
Error code
Third field is most useful one. Bits from 0 to 15 give you real error code:
In case of errors that originated somewhere in Windows API (and that is a lot of them) this will give you System error code (e.g. ERROR_FILE_NOT_FOUND). Even if error originated from some custom source, you can be almost sure that they reused it for same purpose. From this code you can pretty much deduce where problem lies.
Richard Feynman is well known bongo drum player who happened also to be a great theoretical physicist. His areas of work included quantum mechanics and electrodynamics.
Thing that separates him from great deal of big names in Physics is his passion for explaining complex things in simple manner.
Microsoft Research collected some his lectures (The Messenger Series given at Cornell University) in Tuva project. These lectures are definitely something everybody should take a look at.
I wrote quite a lot about virtual disk support in Windows 7. I even gave some C# code on how to use it. Single thing that I haven’t done is to actually make complete program with it. That is changed now.
Idea for this program is quite similar to VhdMount. Difference here is that this program uses native virtual disk support brought to you with Windows 7.
Since I hated necessity of going through Disk Management each time I want to perform attach (a.k.a. mount), there is also right-click support for .vhd files and for already mounted drives. Just select detach on any virtual drive’s context menu and program will find itself which file that is.
While this program is not completed yet, I see no reason why you should not test it and check whether you like it.
Once upon a time I created Windows gadget. Since I wanted to distribute it, I just uploaded it to my site I thought I was done with it. However, once I tried to download it, I got famous 404 “The page cannot be found” message. I double-checked everything and file was there. What wasn’t there is ability of IIS to handle it.
In order for IIS to know what to do with it, there is little piece of something called MIME type. I will not go into deep definitions of it, but it is sufficient to say that “gadget” extension should be defined as “application/x-windows-gadget”. Once that task is done, file can be downloaded without furher problems.