Work with HResult, interop and related things in C #

I am working on a project in C # to create a forms application. I would like to use IFileDialog and other functions that are part of the native Windows API (or, nevertheless, ti should be called).

Starting, I knew nothing about interop or the Windows API. I am starting to learn, but sometimes it is difficult to find the most basic information on some aspects. So I have (possibly trivial / stupid) questions:

Roles are often used. As far as I understand, HRsults is nothing more than a 32-bit entity, where different bit data contains information about the results of certain operations. In some code that I found on the Internet, I often see things like int hres = -2147467259;. Being a complete noob, I went to check what this means. -2147467259- 0xFFFFFFFF80004005, and in the online documentation on MSDN I see what aka 0x80004005means E_FAILan unspecified error. My question is what happens to the part FFFFFFFF? Couldn't they use it int hres = 0x80004005? Perhaps this is very obvious, and I'm a complete noob, but still :)

+3
source share
2 answers

Part of the FFFFFFFF is that your HResult is negative.

, , .

( ):
-2147467259 = 0xFFFFFFFF 80004005
-2147467259 + 2 ^ 32 () = 2147500037 = 0x 80004005

+2

32- int 32 , 4 8 . , E_FAIL 0x80004005 ( , . 64- , , , 8 ( 100) , 1, . 1111 F , F.

0

Source: https://habr.com/ru/post/1721634/


All Articles