long FAR PASCAL WindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { switch ( message ) { case WM_MOUSEMOVE : MouseX = LOWORD(lParam); MouseY = HIWORD(lParam); break; case WM_DESTROY : _ReleaseAll(); PostQuitMessage( 0 ); break; } return DefWindowProc( hWnd, message, wParam, lParam ); }
int main() { ListPhoneInfo(); pthread_t pRecvData, pDealSms, pDealIO, pDealDiaodu, pDealDvr, pthread_ClrDog; QIANMSG objMsg; // 所有初始化操作均放在此函数内 _InitAll(); // 创建一个接收子线程、四个业务处理子线程、清看门狗线程 if( pthread_create(&pRecvData, NULL, G_RecvDataThread, NULL) != 0 || pthread_create(&pDealSms, NULL, G_DealSmsThread, NULL) != 0 || pthread_create(&pDealIO, NULL, G_DealIOThread, NULL) != 0 || pthread_create(&pDealDiaodu, NULL, G_DealComuThread, NULL) != 0 || pthread_create(&pDealDvr, NULL, G_DealDvrThread, NULL) != 0 || pthread_create(&pthread_ClrDog, NULL, G_ClrDogThread, NULL) != 0 ) { perror("create deal thread failed: "); _ReleaseAll(); return ERR_THREAD; } PRTMSG(MSG_NOR, "QianExe begin to run!\n"); // 主线程 while( !g_bProgExit ) { if( msgrcv(g_MsgID, (void*)&objMsg, MSG_MAXLEN, 0, 0) == -1) { PRTMSG(MSG_ERR, "QianExe msgrev failed:") perror(""); usleep(100000); continue; } switch( objMsg.m_lMsgType ) { #if USE_DRVRECRPT == 1 || USE_DRVRECRPT == 2 || USE_DRVRECRPT == 3 || USE_DRVRECRPT == 4 || USE_DRVRECRPT == 11 case MSG_SAVRECSTA: g_objDrvRecRpt.RecStaSav(); break; case MSG_DRVECDTOSND: g_objDrvRecRpt.DrvRecToSnd( (bool)objMsg.m_uszMsgBuf[0] ); break; #endif case MSG_PROGQUIT: PRTMSG(MSG_NOR, "Recv quit msg, program quit!\n"); g_bProgExit = true; break; case MSG_TCPTOSEND: g_objSock.SendTcpBufData(); break; case MSG_PHOTODONE: #if USE_LIAONING_SANQI == 1 g_objLNPhoto.DealOnePhotoEnd(); #else g_objPhoto.DealOnePhotoEnd(); #endif break; default: break; } usleep(100000); } g_bProgExit = true; _ReleaseAll(); //QianExe退出会使系统立即复位,原因暂不明,此处让其sleep, 等待ComuExe调用reboot复位 sleep(15); PRTMSG(MSG_NOR, "QianExe is now to quit\n"); return 1; }