CreateThread The CreateThread function creates a thread to execute within the address space of the calling process. HANDLE CreateThread( LPSECURITY_ATTRIBUTES lpThreadAttributes, // pointer to security attributes DWORD dwStackSize, // initial thread stack size LPTHREAD_START_ROUTINE lpStartAddress, // pointer to thread function LPVOID lpParameter, // argument for new thread DWORD dwCreationFlags, // creation flags LPDWORD lpThreadId // pointer to receive thread ID );
不会用?呵呵,不会吧?也许你没有说清楚你的要求!
The CreateThread function creates a thread to execute within the address space of the calling process. HANDLE CreateThread(
LPSECURITY_ATTRIBUTES lpThreadAttributes, // pointer to security attributes
DWORD dwStackSize, // initial thread stack size
LPTHREAD_START_ROUTINE lpStartAddress, // pointer to thread function
LPVOID lpParameter, // argument for new thread
DWORD dwCreationFlags, // creation flags
LPDWORD lpThreadId // pointer to receive thread ID
);
多的一塌糊涂!
LPSECURITY_ATTRIBUTES lpThreadAttributes, // pointer to security attributes
DWORD dwStackSize, // initial thread stack size
LPTHREAD_START_ROUTINE lpStartAddress, // pointer to thread function
LPVOID lpParameter, // argument for new thread
DWORD dwCreationFlags, // creation flags
LPDWORD lpThreadId // pointer to receive thread ID
);
不明白有什么问题。。
CWinThread *m_pPrnThread = AfxBeginThread(PageFunctionThread, (LPVOID)this, THREAD_PRIORITY_NORMAL);PageFunctionThread是你在线程中要完成功能的函数,可以这么写:
UINT PageFunctionThread(LPVOID lParam)
{
...
CPageProcess *pDlg = (CPageProcess *)lParam;
...
}(LPVOID)this是你要传给线程的参数,(LPVOID)this就是把当前类的指针传过去,你就可以在线程中操作当前类的变量和函数.线程的结束和同步才是最大的问题,不过这要看你程序的具体要求.