Windows programming -- a macro definition of _ beginthreadex

Source: Internet
Author: User


It is written as a macro definition. This is because it is difficult to convert the type of the parameter values every time.

 

 #define BEGINTHREADEX(psa, cbStack, pfnStartAddr,   \
pvParam, fdwCreate, pdwThreadId) \
((HANDLE)_beginthreadex( \
(void *) (psa), \
(unsigned) (cbStack), \
(PTHREAD_START) (pfnStartAddr), \
(void *) (pvParam), \
(unsigned) (fdwCreate), \
(unsigned*) (pdwThreadId)))

 

 

 

Unsignedlong _ beginthreadex (void * security, unsigned stack_size, unsigned (_ stdcall * start_address) (void *), void * arglist, unsigned initflag, unsigned * thrdaddr );

 

// 1st parameters: Security Attribute. NULL is the default security attribute.
// 2nd parameters: Specifies the thread stack size. If it is 0, the thread stack size is the same as that of the thread that created it. Generally, 0 is used.
// 3rd parameters: Specify the address of the thread function, that is, the address of the function called and executed by the thread (use the function name to indicate the address)
// 4th parameters: the pointer of the parameter passed to the thread. You can pass in the object pointer and then convert it to the pointer of the corresponding class in the thread function.
// 5th parameters: the initial state of the thread; 0: run immediately; CREATE_SUSPEND: suincluded (suspended)
// 6th parameters: the address used to record the thread ID

FangSH

2011-01-05

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.