DWORD_PTR WINAPI SetThreadAffinityMask(
__in HANDLE hThread,
__in DWORD_PTR dwThreadAffinityMask
);
But I see code on the web that calls it like
SetThreadAffinityMask(GetCurrentThread(),1).
I'm confused as how it could be passing the value "1" when the prototype is
calling for a DWORD_PTR.
Assuming I have a DWORD variable defined like:
DWORD mask = 1;
Should it be called:
SetThreadAffinityMask(GetCurrentThread(),mask);
or
SetThreadAffinityMask(GetCurrentThread(),&mask);
A DWORD_PTR is not a pointer. It is an unsigned integer that is the same
size as a pointer. Thus, in Win32 a DWORD_PTR is the same as a DWORD (32
bits), and in Win64 it is the same as a ULONGLONG (64 bits).
So you would do this:
DWORD_PTR mask = 1;
SetThreadAffinityMask(GetCurrentThread(),mask);
Yes, Tom has provided the correct answer. DWORD_PTR is a Windows data type.
It is not a pointer type, but a type to hold pointer precision value for
arithmetic operations, see the link below for more details:
"Windows Data Types"
http://msdn2.microsoft.com/en-us/library/aa383751.aspx
In the VC++&Windows header files, you will see that DWORD_PTR will be
defined as "ULONG_PTR":
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
Which is again defined as C language build-in type "unsigned long":
typedef _W64 unsigned long ULONG_PTR, *PULONG_PTR;
"unsigned long" is 4 bytes in C language(different from C# language which
is 8 bytes):
"Data Type Ranges"
http://msdn2.microsoft.com/en-us/library/s3f49ktz.aspx
The best way to determine if the parameter will be modified&returned from
an API is checking its "[in]" or "[out]" attribute in the MSDN. For
example, the MSDN has "[in]" for the dwThreadAffinityMask parameter of
SetThreadAffinityMask which means that SetThreadAffinityMask will not
modify the dwThreadAffinityMask parameter, but just receive value from this
parameter.
Hope this helps.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.