一个典型的例子解决常见的高级Windows程序设计问题[7]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 hightech 的 blog

  // waitforsingleobject will check the first parameter,
  // if it is signaled,the loop will break.
  //
  
  if(waitforsingleobject(pevent->m_hobject,0)==wait_object_0)
   return (uint) -1;

  waitforsingleobject(dwchangehandles[1],infinite);
  postmessage (hwnd,wm_user_thread_file_changed,0,0);
  findnextchangenotification(dwchangehandles);
 ---------------------------------------------------------------------------*/
  
  //
  // wait for notification.
  //
  
  dwwaitstatus = waitformultipleobjects(3, dwchangehandles,
             false, infinite);
  if (dwwaitstatus == wait_object_0 + 2) return (uint) -1;          

  switch (dwwaitstatus)
   {
   case wait_object_0:
   
    //
    // a file was created or deleted in c:\windows.
    // refresh this directory and restart the
    // change notification. refreshdirectory is an
    // application-defined function.
    //
    
    postmessage (hwnd,wm_user_thread_file_changed,0,0);
    findnextchangenotification(dwchangehandles[0]);
    break;

   case wait_object_0 + 1:
   
    //
    // a directory was created or deleted in c:\.
    // refresh the directory tree and restart the
    // change notification. refreshtree is an
    // application-defined function.
    //

     postmessage (hwnd,wm_user_thread_file_changed,0,0);
    findnextchangenotification( dwchangehandles[1]);
    break;
   }
  }
 

 delete[] dwchangehandles;
 return 0;
}

//---------------------------------------------------------------------------------------
//
// function: long cmainwindow::onfilechanged(wparam wparam, lparam lparam)
// purpose:
// comments:
//---------------------------------------------------------------------------------------

long cmainwindow::onfilechanged(wparam wparam, lparam lparam)
{
 //
 // add process sentence if file changed here.
 //

 return 0;

本文关键:线程,状态栏小图标,文件实时监视
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top