字体
第(4/5)页
关灯
   存书签 书架管理 返回目录
个参数。

    ? lpParcomter:线程函数的参数。

    ? dwCreationFlags:线程创建标志。如果是CREATE_SUSPENDED,则线程的初始状态

    为挂起,直到调用了RescomThread才开始执行。如果为0,线程创建后即开始执行。

    ? lpThreadId:存放线程标志的变量指针。

    2.C 运行库函数_beginthreadex

    _beginthreadex 和Win32API 函数CreateThread 非常类似。如果调用成功,返回新创建线

    程的句柄,否则返回-1。它们的参数几乎完全相同。函数原型如下:

    unsigned long _beginthread(

    void( __cdecl *start_address )( void * ),

    枫叶文学网www.fywxw.com

    Visual C++ 6.0 程序设计从入门到精通

    ·210·

    unsigned stack_size,

    void *arglist

    );

    unsigned long _beginthreadex(

    void *security, unsigned stack_size,

    unsigned ( __stdcall *start_address )( void * ),

    void *arglist,

    unsigned initflag,

    unsigned *thrdaddr

    );

    函数中主要参数的意义如下。

    ? start_address:线程的入口地址。

    ? stack_size:初始堆栈大小。

    ? arglist:传给线程的参数。

    ? security:安全属xìng。

    ? initflag:线程创建标志。

    ? thrdaddr:存放线程标志的变量指针。

    3.调用函数AfxBeginThread

    MFC 对Win32 的线程cāo作做了封装,可以通过调用AfxBeginThread 创建一个线程对象,

    函数AfxBeginThread 有两种调用方式,函数原型如下:

    CWinThread* AfxBeginThread(

    AFX_THREADPROC pfnThreadProc,

    LPVOID pParam, int nPriority = THREAD_PRIORITY_NORMAL,

    UINT nStackSize = 0,

    DWORD dwCreateFlags = 0,

    LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL

    );

    CWinThread* AfxBeginThread(

    CRuntcomClass* pThreadClass,

    int nPriority = THREAD_PRIORITY_NORMAL,

    UINT nStackSize = 0,

    DWORD dwCreateFlags
上一页 目录 下一页