各位高手帮忙,我打算创建一个进程或线程来完成一些操作,就是在不影响我当前的一个动作的情况下,这个应该是怎么写呢?

解决方案 »

  1.   

    CreateThread或者CreateProcess即可!
    不会用?呵呵,不会吧?也许你没有说清楚你的要求!
      

  2.   

    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
    );
      

  3.   

    类似的代码:http://www.vckbase.com/document/listdoc.asp?mclsid=13&sclsid=1305
    多的一塌糊涂!
      

  4.   

    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
    );
    不明白有什么问题。。
      

  5.   

    Win32多线程编程和Windows核心编程两本书
      

  6.   

    启动线程:
    CWinThread *m_pPrnThread = AfxBeginThread(PageFunctionThread, (LPVOID)this, THREAD_PRIORITY_NORMAL);PageFunctionThread是你在线程中要完成功能的函数,可以这么写:
    UINT PageFunctionThread(LPVOID lParam)
    {
        ...
        CPageProcess *pDlg = (CPageProcess *)lParam;
        ...
    }(LPVOID)this是你要传给线程的参数,(LPVOID)this就是把当前类的指针传过去,你就可以在线程中操作当前类的变量和函数.线程的结束和同步才是最大的问题,不过这要看你程序的具体要求.
      

  7.   

    AfxBeginThread创建一个线程,线程函数中放实现的代码