What is the asterisk on a data type in a Windows API declaration?
I know what (for example) a DWORD
is, it's a four-byte unsigned long integer.
But what does DWORD *
with an asterisk before the parameter name mean, as seen here:
HRESULT UrlUnescape(
__inout PTSTR pszURL,
__out_opt PTSTR pszUnescaped,
__inout_opt开发者_如何转开发 DWORD *pcchUnescaped,
DWORD dwFlags
);
UPDATE
It occurs to me I had a few additional hints that it was a pointer. The first is that the parameter name starts with a p. The other is that it is an in/out parameter, and the only way the callee could alter the value of the caller's variable is if a pointer is passed rather than a value. Of course, the strings are pointers too, and they don't use the asterisk, but that's because a string can't be passed by value so it would be redundant, while an integer certainly can be passed by value (and often/usually is).
It means that pcchUnescaped
is pointer to an object of type DWORD
. That's normal C, nothing specifically related to the Windows API.
It means a pointer to a DWORD
in the memory.
From MSDN:
A DWORD is a 32-bit unsigned integer (range: 0 through 4294967295 decimal). Because a DWORD is unsigned, its first bit (Most Significant Bit (MSB)) is not reserved for signing.
精彩评论