How can you know whether a parameter or return type is a handle type? #2072
-
|
Handles are merely pointers to objects. The size of handles are therefore dependent on the platform - 32 bit on 32 bit machines and 64 bit on 64 bit machines. Take for example MSIHANDLE. .class public sequential ansi sealed beforefieldinit Windows.Win32.System.ApplicationInstallationAndServicing.MSIHANDLE
extends [netstandard]System.ValueType
{
.custom instance void [Windows.Win32.winmd]Windows.Win32.Foundation.Metadata.RAIIFreeAttribute::.ctor(string) = (
01 00 0e 4d 73 69 43 6c 6f 73 65 48 61 6e 64 6c
65 00 00
)
.custom instance void [Windows.Win32.winmd]Windows.Win32.Foundation.Metadata.InvalidHandleValueAttribute::.ctor(int64) = (
01 00 ff ff ff ff ff ff ff ff 00 00
)
.custom instance void [Windows.Win32.winmd]Windows.Win32.Foundation.Metadata.InvalidHandleValueAttribute::.ctor(int64) = (
01 00 00 00 00 00 00 00 00 00 00 00
)
.custom instance void [Windows.Win32.winmd]Windows.Win32.Foundation.Metadata.NativeTypedefAttribute::.ctor() = (
01 00 00 00
)
// Fields
.field public uint32 Value
} // end of class Windows.Win32.System.ApplicationInstallationAndServicing.MSIHANDLEAlright, so we see that there's an InvalidHandleValueAttribute on it, which is quite revealing that it's a handle. The RAIIFreeAttribute also strongly hints that it's a handle, since we can release it with a separate function. But it's a What about HWND? .class public sequential ansi sealed beforefieldinit Windows.Win32.Foundation.HWND
extends [netstandard]System.ValueType
{
.custom instance void [Windows.Win32.winmd]Windows.Win32.Foundation.Metadata.AlsoUsableForAttribute::.ctor(string) = (
01 00 06 48 41 4e 44 4c 45 00 00
)
.custom instance void [Windows.Win32.winmd]Windows.Win32.Foundation.Metadata.NativeTypedefAttribute::.ctor() = (
01 00 00 00
)
// Fields
.field public void* Value
} // end of class Windows.Win32.Foundation.HWNDDoesn't seem to have any of the two attributes like MSIHANDLE does. It does, however, have a There are a lot of handle types, and it will be error prone to try to list them all. I appreciate all guidance on this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is a wrong assumption, because as you have noticed, there are handles that have fixed sizes of integers, like MSIHANDLE. From msi.h typedef unsigned long MSIHANDLE; Trust the source Luke :-D |
Beta Was this translation helpful? Give feedback.
This is a wrong assumption, because as you have noticed, there are handles that have fixed sizes of integers, like MSIHANDLE.
From msi.h
Trust the source Luke :-D