编译出错:
mmmView.cpp(123) : error C2664: '_beginthreadex' : cannot convert parameter 3 from 'unsigned int (void *)' to 'unsigned int (__stdcall *)(void *)'None of the functions with this name in scope match the target type编译环境:windowsXP,VC++6.0
创建的MFC AppWizard工程mmm,
在视图类mmmview.h文件中添加了#include <process.h>
protected:
    UINT  __stdcall CommThread(LPVOID pParam);在mmmView.cpp文件中有如下相关代码:void CMmmView::OnInitialUpdate() 
{
    CView::OnInitialUpdate();

    // TODO: Add your specialized code here and/or call the base class  ....... 
   
   m_pThread=(HANDLE) _beginthreadex(NULL,0,CommThread,this,CREATE_SUSPENDED,&nDummy);//开辟外部控制线程 
   ...
}
UINT __stdcall  CMmmView::CommThread(LPVOID  pParam) 

   CMmmView *pView = (CMmmView *)pParam; 
   while(1) 
  { 
      CTime cNowTime = CTime::GetCurrentTime(); 
      tNow = cNowTime.GetTime(); 
      struct _timeb timebuffer; 
      ftime(&timebuffer); 
      int nNowMillSecond = timebuffer.millitm; 
      /// 
      tLast = cLastColtTime[0].GetTime(); 
      if((tNow - tLast)*1000 + (nNowMillSecond - nMillSecond[0]) > 800) 
      pView->SetCommVal();                      
      Sleep(100); 
   } 

是哪里出了问题?
请指教,不胜感激

解决方案 »

  1.   

    UINT __stdcall  CMmmView::CommThread(LPVOID  pParam) 的声明是否有static
      

  2.   

    protected:
    static     UINT  __stdcall CommThread(LPVOID pParam);
      

  3.   

    UINT __stdcall CMmmView::CommThread(LPVOID pParam)<====这里不需要__stdcall
    {
    CMmmView *pView = (CMmmView *)pParam;
    while(1)
    {
    CTime cNowTime = CTime::GetCurrentTime();
    tNow = cNowTime.GetTime();
    struct _timeb timebuffer;
    ftime(&timebuffer);
    int nNowMillSecond = timebuffer.millitm;
    ///
    tLast = cLastColtTime[0].GetTime();
    if((tNow - tLast)*1000 + (nNowMillSecond - nMillSecond[0]) > 800)
    pView->SetCommVal();
    Sleep(100);
    }
    }
    在声明的时候写上
    static UINT __stdcall CommThread(LPVOID pParam);
      

  4.   

    上述错误解决了,感谢各位
    但是又出现了新的问题,改后的函数定义为:UINT   CMmmView::CommThread(LPVOID  pParam) 

        CMmmView *pView = (CMmmView *)pParam; 
        while(1) 
        { 
           CTime cNowTime = CTime::GetCurrentTime(); 
           pView->tNow = cNowTime.GetTime(); 
           struct _timeb timebuffer; 
          _ftime(&timebuffer); 
          int nNowMillSecond = timebuffer.millitm; 
          pView->tLast =pView->cLastColtTime.GetTime(); 
          if((pView->tNow -pView-> tLast)*1000 + (nNowMillSecond - nMillSecond[0]) > 800) 
          pView->SetCommVal();                    
          Sleep(100); 
       } 
    } 出现error为mmm\mmmView.cpp(155) : error C2676: binary '*' : 'class CTimeSpan' does not define this operator or a conversion to a type acceptable to the predefined operator if((pView->tNow -pView-> tLast)*1000 + (nNowMillSecond - nMillSecond[0]) > 800) 这是从网上找得代码,我也懂是做什么的,各位再帮忙看看