evc小项目杂记(2)
两个wince小程序,Gprs功分器测试,和开关机拨号测试,都已经顺利完工,现在有空回头学一下之前一知半解的细节问题。 1. 在cedit中打印log -- //在edittext中打印信息voidCSimTestDlg::ShowMessage(CStringstrMsg){ CEdit*pMsgInfo = (CEdit*)GetDlgItem(IDC
两个wince小程序,Gprs功分器测试,和开关机拨号测试,都已经顺利完工,现在有空回头学一下之前一知半解的细节问题。
1. 在cedit中打印log
--
//在edittext中打印信息 voidCSimTestDlg::ShowMessage(CStringstrMsg) { CEdit*pMsgInfo = (CEdit*)GetDlgItem(IDC_EDIT_TIPS); pMsgInfo->SetSel(pMsgInfo->GetWindowTextLength(),pMsgInfo->GetWindowTextLength()); //光标移动到当前所显示文本的末尾 pMsgInfo->ReplaceSel(strMsg); //在光标末尾插入字符串 pMsgInfo->ReplaceSel(_T("\r\n")); }
2.写log文件
--
//自己写的,解决了中文乱码和末尾有小方框的问题,可能还有隐患没发现 //写log记录到\ResidentFlash\开关机测试log.txt int CSimTestDlg::writelog(CString logStr){ CFilemyFile; char*pData = new char[500]; TCHAR*pStrLog = new TCHAR[500]; CStringstr_time = _T(""); CStringstr_result = _T(""); CStringstrFile = _T(""); SYSTEMTIMEsys; GetLocalTime(&sys ); str_time.Format(_T("%4d/%02d/%02d%02d:%02d:%02d"),sys.wYear,sys.wMonth,sys.wDay,sys.wHour,sys.wMinute,sys.wSecond); str_result= str_time + logStr; intfileLength = str_result.GetLength(); wcscpy(pStrLog,(LPCTSTR)str_result); intcpylen =MyWideCharToMultiByte_test(pStrLog,pData,fileLength*2);//获得unicode转Ansi之后的长度,说明http://blog.csdn.net/sky1415/article/details/4137872 strFile= _T("\\ResidentFlash\\开关机测试log.txt"); myFile.Open(strFile,CFile::modeCreate | CFile::modeWrite |CFile::typeBinary|CFile::modeNoTruncate);//modeNoTruncate表示为续写方式 myFile.SeekToEnd(); myFile.Write(pData,cpylen); myFile.Flush(); myFile.Close(); delete[]pData; delete[]pStrLog; return0; } intCGPRS_SIGNAL_TESTDlg::MyWideCharToMultiByte_test(WCHAR*wchars, CHAR* schars,int scharsLen) { memset(schars,0, scharsLen); CStringm_snd = wchars; intlen = m_snd.GetLength(); CStringtmpstr(m_snd); //复制要发送的字符串 intmultibytelen = WideCharToMultiByte(//计算从Unicode转换到Ansi后需要的字节数 CP_ACP,//根据ANSI codepage转换 WC_COMPOSITECHECK|WC_DEFAULTCHAR, //转换出错用缺省字符代替 (LPCWSTR)tmpstr.GetBuffer(len),//要转换的字符串地址 len,//要转换的个数 0,//转换后字符串放置的地址 0,//最多转换字符的个数,为0表示返回转换Unicode后需要多少个字节 0,//缺省的字符:"\0" 0//缺省的设置 ); WideCharToMultiByte(//转换Unicode到Ansi CP_ACP,WC_COMPOSITECHECK |WC_DEFAULTCHAR, (LPCWSTR)tmpstr.GetBuffer(len), len,(char*)schars, //转换到缓冲区中 scharsLen,//最多个字节 0,0); returnmultibytelen; }
3. 调用系统程序并打开窗口
-- CreateProcess:http://baike.baidu.com/link?url=aLC_mEQNRDbEOf_wfXOxeH1Q2Q-XpIr9mXQDZKnHLXmPq-1niVJhYH05eTtCEnnE
#define FILE_PLAY_EXEC _T("\\ResidentFlash\\player\\PLAYER.EXE") #define FILE_PLAY_DATA _T("\\ResidentFlash\\PandaNormal.avi") PROCESS_INFORMATIONinfo; CreateProcess(FILE_PLAY_EXEC,FILE_PLAY_DATA, NULL, NULL, FALSE,CREATE_NEW_CONSOLE, NULL, NULL, NULL,&info);
4. 定时器设置
--
//.cpp注册定时器 BEGIN_MESSAGE_MAP(CGPRS_SIGNAL_TESTDlg,CDialog) //{{AFX_MSG_MAP(CGPRS_SIGNAL_TESTDlg) ON_BN_CLICKED(IDC_BUTTON_START,OnButtonStart) ON_BN_CLICKED(IDC_BUTTON_STOP,OnButtonStop) ON_WM_TIMER()//定时器设置 ON_MESSAGE(WM_GPRSRECV,OnGPRSRecv)//接收消息 //}}AFX_MSG_MAP END_MESSAGE_MAP() //.cpp实现OnTimer,对话框定时消失 voidCGPRS_SIGNAL_TESTDlg::OnTimer(UINT_PTRnIDEvent) { //TODO: Add your control notification handler code here HWNDhWnd = ::FindWindow(NULL, _T("提示")); //查找标题为B的窗口,返回窗口句柄 if(hWnd) //如果窗口句柄存在 { ::SendMessage(hWnd,WM_CLOSE,NULL, NULL);//可行 //DestroyWindow(); //关闭整个窗口,不行 //keybd_event(13,0,0,0);//模拟回车键按下,有啪的一声 //keybd_event(VK_RETURN,0,0,0); //模拟回车键按下,有啪的一声 } KillTimer(nIDEvent); //关闭定时器 CDialog::OnTimer(nIDEvent); } //.h文件中声明 afx_msg void OnTimer(UINT_PTRnIDEvent);//接收消息
5.设置控件背景色
--
//.h文件中,注册函数 afx_msg HBRUSH OnCtlColor(CDC* pDC,CWnd*pWnd, UINT nCtlColor); //cpp中重载消息响应函数 BEGIN_MESSAGE_MAP(CLytNandTestDlg, CDialog) //{{AFX_MSG_MAP(CLytNandTestDlg) ON_WM_CTLCOLOR() //}}AFX_MSG_MAP END_MESSAGE_MAP() //cpp文件中实现方法,根据id设置不同颜色 /************************************************************************/ /* UI显示 */ /************************************************************************/ HBRUSH CLytNandTestDlg::OnCtlColor(CDC*pDC,CWnd* pWnd, UINT nCtlColor) { HBRUSHhbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); //Are we painting theIDC_MYSTATIC control? We can use //CWnd::GetDlgCtrlID() to perform the most efficient test. if(pWnd->GetDlgCtrlID() == IDC_SHOW) { RETAILMSG(1,(_T("OnCtlColor\n"))); //Set the text color to red. pDC->SetTextColor(RGB(255,255,255)); m_brush= ::CreateSolidBrush( RGB(0,0,255)); //Set the background mode fortext to transparent //so background will show thru. pDC->SetBkMode(TRANSPARENT); //Return handle to our CBrushobject. hbr= m_brush; } returnhbr; }
6.注册表读写
-- 调用示例
//修改注册表,自动开机 reg->WriteRegMultiString(HKEY_LOCAL_MACHINE,_T("init\\"),L"Launch80",_T("\\ResidentFlash\\OurAPP\\开关机测试v1.3.exe")); reg->DeleteRegValue(HKEY_LOCAL_MACHINE,_T("init\\"),L"Launch80");
源码
/*************************************************************************** $Id$ Copyright (C) Centerm Information Co.,Ltd.All rights reserved. Model Name: Reg.cpp Description: 注册表测试 Environment: WinCE5.0、6.0 History: <author> <time> <version> <desc> Wangxuehong 2009-2-10 2.00 创建 ***************************************************************************/ #include "StdAfx.h" #include "Reg.h" // 向注册表写入字符串 void CReg::WriteRegString(HKEY hKey,TCHAR*Key, TCHAR *Name, TCHAR *Value, DWORD size) { HKEYhk; LONGreCode; DWORDdwDisposition; reCode=RegCreateKeyEx(hKey,Key,0,TEXT("S"),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hk,&dwDisposition); if(reCode== ERROR_SUCCESS) { RegSetValueEx( hk,Name,0, REG_SZ,(LPBYTE)Value, (size + 1)*2 ); RegCloseKey(hk); } } // 向注册表写入字符串 void CReg::WriteRegStr(HKEY hKey,TCHAR*Key, TCHAR *Name, TCHAR *Value) { HKEYhk; LONGreCode; DWORDdwDisposition; reCode=RegCreateKeyEx(hKey,Key,0,TEXT("S"),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hk,&dwDisposition); if(reCode== ERROR_SUCCESS) { RegSetValueEx(hk,Name,0, REG_SZ,(LPBYTE)Value, (lstrlen(Value)+1)*sizeof(TCHAR)); RegCloseKey(hk); } } // 向注册表写入多字符串 void CReg::WriteRegMultiString(HKEYhKey,TCHAR *Key, TCHAR *Name, TCHAR *Value) { HKEY hk; LONG reCode; DWORD dwDisposition; TCHAR *pStr; WORD Strl; pStr = Value; Strl = 0; while(*pStr) { while(*pStr) { pStr++; Strl++; } pStr++; Strl++; } reCode=RegCreateKeyEx(hKey,Key,0,TEXT("S"),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hk,&dwDisposition); if(reCode== ERROR_SUCCESS) { RegSetValueEx(hk,Name,0,REG_MULTI_SZ, (LPBYTE)Value, (Strl+1)*2); RegCloseKey(hk); } } // 向注册表写入二进制 void CReg::WriteRegBin(HKEY hKey,TCHAR*Key, TCHAR *Name, VOID *Value, DWORD size) { HKEYhk; LONGreCode; DWORDdwDisposition; reCode=RegCreateKeyEx(hKey,Key,0,TEXT("S"),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hk,&dwDisposition); if(reCode==ERROR_SUCCESS) { RegSetValueEx(hk,Name,0,REG_BINARY, (LPBYTE)Value, size*2); RegCloseKey(hk); } } // 向注册表写入INT void CReg::WriteRegInt(HKEY hKey, TCHAR*Key,TCHAR *Name, DWORD Value) { LONGreCode; HKEYhk; DWORDdwDisposition; reCode=RegCreateKeyEx(hKey,Key,0,TEXT("S"),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, NULL,&hk,&dwDisposition); if(reCode== ERROR_SUCCESS) { RegSetValueEx(hk,Name,0,REG_DWORD, (LPBYTE)&Value, 4); RegCloseKey(hk); } } // 向注册表写入DWORD BOOL CReg::ReadRegDWord(HKEY hKey,TCHAR*Key, TCHAR *Name,DWORD *dwValue) { HKEY hk; DWORD data = 0; DWORD DataSize = sizeof(DWORD); DWORD dwType = 0; LONG reCode; reCode=RegOpenKeyEx(hKey,Key, 0, KEY_READ, &hk); if(reCode== ERROR_SUCCESS) { reCode= RegQueryValueEx(hk, Name,NULL, &dwType, (BYTE*)&data,&DataSize); RegCloseKey(hk); if(reCode==ERROR_SUCCESS) *dwValue = data; elsereturn FALSE; } else return FALSE; returnTRUE; } // 从注册表读取一个INT DWORD CReg::ReadRegInt(HKEY hKey,TCHAR*Key, TCHAR *Name) { HKEY hk; DWORD data = 0; DWORD DataSize = sizeof(DWORD); DWORD dwType = 0; LONG reCode; reCode= RegOpenKeyEx(hKey, Key, 0, KEY_READ, &hk); if(reCode== ERROR_SUCCESS) { reCode= RegQueryValueEx(hk, Name,NULL, &dwType, (BYTE*)&data,&DataSize); RegCloseKey(hk); } else data= 0; returndata; } // 从注册表读取字符串 DWORD CReg::ReadRegString(HKEY hKey,TCHAR*Key, TCHAR *Name, TCHAR* data) { HKEYhk; LONGreCode; DWORDDataSize = 1024; DWORDdwType; reCode= RegOpenKeyEx(hKey,Key,0,KEY_READ,&hk); if(reCode== ERROR_SUCCESS) { reCode=RegQueryValueEx(hk,Name,NULL,&dwType,(BYTE*)data,&DataSize); if(dwType != REG_SZ &&dwType != REG_MULTI_SZ ) { DataSize= 0; data[0]= 0; } RegCloseKey(hk ); returnDataSize; } else { data[0]= 0; return0; } } // 从注册表读取二进制 DWORD CReg::ReadRegBin(HKEY hKey,TCHAR*Key, TCHAR *Name, TCHAR* data) { HKEYhk; LONGreCode; DWORDDataSize = 1024; DWORDdwType; reCode= RegOpenKeyEx(hKey,Key,0,KEY_READ,&hk); if(reCode == ERROR_SUCCESS ) { reCode=RegQueryValueEx(hk,Name,NULL,&dwType,(BYTE*)data,&DataSize); RegCloseKey(hk); returnDataSize; } else { data[0]= 0; return0; } } // 删除注册表内容 void CReg::DeleteRegValue(HKEYhKey,TCHAR*Key,TCHAR *Name) { HKEYhk; LONGreCode; reCode= RegOpenKeyEx( hKey, Key, 0,KEY_ALL_ACCESS, &hk ); if(reCode== ERROR_SUCCESS) { reCode= RegDeleteValue(hk,Name); RegCloseKey(hk); } } // 复制注册表内容 BOOL CReg::CopyReg(HKEY hSKey, TCHAR*SKey,TCHAR *SName,HKEY hDKey, TCHAR *DKey, TCHAR *DName) { BOOLret = FALSE; HKEYshk, dhk; BYTEdata[1024]; DWORDDataSize = 1024; DWORDdwType, dwDisposition; if(RegOpenKeyEx(hSKey, SKey, 0, KEY_READ, &shk) == ERROR_SUCCESS) { if(RegCreateKeyEx(hDKey,DKey,0,TEXT("S"),REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS, NULL,&dhk,&dwDisposition)== ERROR_SUCCESS) { if(RegQueryValueEx(shk,SName,NULL,&dwType,data,&DataSize)==ERROR_SUCCESS) { if(RegSetValueEx(dhk,DName,0,dwType,data,DataSize) == ERROR_SUCCESS) { ret=TRUE; } } RegCloseKey(dhk); } RegCloseKey(shk); } returnret; } //设置NumLock状态 void CReg::SetNumLockStatus(BOOL NumLockOn) { SHORTKeyStatus; KeyStatus= GetKeyState(VK_NUMLOCK); if(KeyStatus&& 0x01)//检查状态为开 { if(!NumLockOn) { keybd_event(VK_NUMLOCK,(BYTE)0xe045,0,0); keybd_event(VK_NUMLOCK,(BYTE)0xe045,KEYEVENTF_KEYUP,0); } } else//检查状态为关 { if(NumLockOn) { keybd_event(VK_NUMLOCK,(BYTE)0xe045,0,0); keybd_event(VK_NUMLOCK,(BYTE)0xe045,KEYEVENTF_KEYUP,0); } } } //设置NumLock状态 void CReg::SetNumLockStatusFromReg() { BOOLnumlockStatus =ReadRegInt(HKEY_LOCAL_MACHINE,TEXT("SoftWare\\Start"),TEXT("NumLockOn")); SetNumLockStatus(numlockStatus ); } /* ************************************************* *Desc: 保存注册表 *Para: *Return: *Update Record: ************************************************* */ typedef DWORD (*pSaveRegData)(HWND hwnd); BOOL CReg::SaveReg() { #ifndef HIVE_BASED HINSTANCE hstbRegLib=NULL; pSaveRegDatadllSaveRegData; hstbRegLib= LoadLibrary(TEXT("SSReg.dll")); if( hstbRegLib == NULL ) { returnFALSE; } dllSaveRegData= (pSaveRegData) GetProcAddress( hstbRegLib,TEXT("SaveRegData") ); if( dllSaveRegData == NULL ) { returnFALSE; } else { dllSaveRegData(NULL ); } FreeLibrary(hstbRegLib ); #else DWORDdwRet = 0; if(ERROR_SUCCESS == RegFlushKey( HKEY_CURRENT_USER ) ) { //RETAILMSG(DEBUG_BY_AHZIT,(L"RegFlushKey [HKEY_CURRENT_USER]successed.\r\n")); } else { //RETAILMSG(DEBUG_BY_AHZIT,(L"RegFlushKey[HKEY_CURRENT_USER] failed.\r\n")); returnfalse; } dwRet= RegFlushKey( HKEY_LOCAL_MACHINE ); if(ERROR_SUCCESS != dwRet ) { //RETAILMSG(DEBUG_BY_AHZIT,(L"RegFlushKey[HKEY_LOCAL_MACHINE] failed, errorcode:[%ld].\r\n", dwRet)); returnfalse; } else { //RETAILMSG(DEBUG_BY_AHZIT,(L"RegFlushKey [HKEY_LOCAL_MACHINE]successed.\r\n")); } #endif returnTRUE; } </desc></version></time></author>
/*************************************************************************** $Id$ Copyright (C) Centerm Information Co.,Ltd.All rights reserved. Model Name: Reg.h Description: 注册表测试 Environment: WinCE5.0、6.0 History: <author> <time> <version> <desc> Wangxuehong 2009-2-10 2.00 创建 ***************************************************************************/ #pragma once class CReg { public: voidWriteRegString(HKEY hKey, TCHAR *Key, TCHAR *Name, TCHAR *Value,DWORD size); voidWriteRegStr(HKEY hKey, TCHAR *Key, TCHAR *Name, TCHAR *Value); voidWriteRegMultiString(HKEY hKey, TCHAR *Key, TCHAR *Name, TCHAR*Value); voidWriteRegBin(HKEY hKey, TCHAR *Key, TCHAR *Name, VOID *Value, DWORDsize); voidWriteRegInt(HKEY hKey, TCHAR *Key, TCHAR *Name, DWORD Value); BOOLReadRegDWord(HKEY hKey, TCHAR *Key, TCHAR *Name,DWORD *dwValue); DWORDReadRegInt(HKEY hKey, TCHAR *Key, TCHAR *Name); DWORDReadRegString(HKEY hKey, TCHAR *Key, TCHAR *Name, TCHAR* data); DWORDReadRegBin(HKEY hKey, TCHAR *Key, TCHAR *Name, TCHAR* data); voidDeleteRegValue(HKEY hKey,TCHAR *Key,TCHAR *Name); BOOLCopyReg(HKEY hSKey, TCHAR *SKey, TCHAR *SName,HKEY hDKey, TCHAR*DKey, TCHAR*DName); voidSetNumLockStatus(BOOL NumLockOn); voidSetNumLockStatusFromReg(); BOOLSaveReg(); }; </desc></version></time></author>
7. 将系统时间转化为CString, 查询文件是否存在,得到当前绝对路径
--
//系统时间转化为字符串 CString Systime2CString(SYSTEMTIME m_time){ TCHARszDateTime[100] = {0}; _stprintf(szDateTime, _T("%04d/%02d/%02d%02d:%02d:%02d"),m_time.wYear,m_time.wMonth, m_time.wDay,m_time.wHour,m_time.wMinute, m_time.wSecond); CString str = szDateTime; returnstr; } //文件是否存在 BOOL IsFileExist(LPTSTR lpFilePath) { WIN32_FIND_DATAm_fd; if(FindFirstFile(lpFilePath ,&m_fd) ==INVALID_HANDLE_VALUE ) returnFALSE; returnTRUE; } /* //获得当前绝对路径 void GetCurPath(WCHAR* strFilePath) { int i = 0; int sLen = 0; sLen = GetModuleFileName(NULL,strFilePath,260); for(i=sLen;i!=0;i--) { if(strFilePath[i]==WCHAR('\\')) { break; } strFilePath[i]= WCHAR('\0'); } }
8.关机
--
//关机挂起 void CSimTestDlg::halt(){ inttestCnt =mprofile->GetPrivateProfileInt(div,ID_testcnt, 0, iniFilePath); mprofile->WritePrivateProfileInt(div,ID_testcnt, testCnt+1,iniFilePath); Sleep(300); SetSystemPowerState(NULL,POWER_STATE_OFF, POWER_FORCE); }
9.ras拨号
//获取ppp网络状态 BOOL CSimTestDlg::IsConnect() { if(NULL != hRasConn) { RASCONNSTATUS rasConStatus; rasConStatus.dwSize = sizeof(RASCONNSTATUS); RasGetConnectStatus(hRasConn,&rasConStatus); if(RASCS_Connected == rasConStatus.rasconnstate) { return TRUE; } } return FALSE; } //移除已经拨上去的ras void CSimTestDlg::RemoveConnect(){ RASCONNentries[25]; DWORDbufsize=0; DWORDnumEntries=0; bufsize=25*sizeof(RASCONN); entries[0].dwSize=sizeof(RASCONN); RASCONNSTATUSstatus; status.dwSize=sizeof(RASCONNSTATUS); if(RasEnumConnections(entries,&bufsize,&numEntries)==0) { for(DWORDi=0;i<numentries if while retailmsg for ras disconnect break dword winapi pppdtread pdata csimtestdlg dworddwlast dworddwcurrent dwinterval="5000;" intwaitcount="0;" cstringlog='_T("");' cstringlog_whyfail='_T("");' intdialfailreason="0;" pdlg->reDialCnt= 0; DWORDstate_wait_for_event; //是否已经拨号失败即“断开连接” inttestCnt =mprofile->GetPrivateProfileInt(div, ID_testcnt, 0, iniFilePath); while(shouldEndTest==FALSE&& pDlg->reDialCnt m_test_state=STATE_TESTING_DAIL;//正在拨号的提示 //获得当前系统时间 dwLast= GetTickCount(); pDlg->RemoveConnect(); while(pDlg->IsConnect()&&shouldEndTest==FALSE) { if(pDlg->hRasConn!=NULL) { RETAILMSG(1,(_T("退出1\r\n"))); RasHangUp(pDlg->hRasConn); } Sleep(100);//100MS dwCurrent=::GetTickCount(); if(dwCurrent-dwLast>=dwInterval) { pDlg->SetDlgItemText(IDC_STATUS,_T("5s还没退出重启模块.....等待7S"));//ui pDlg->m_gpio=CreateFile(_T("GPI1:"),GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL); if(pDlg->m_gpio!= INVALID_HANDLE_VALUE ) { DeviceIoControl(pDlg->m_gpio,IOCTL_CDMA_OFF,NULL,NULL,NULL,NULL,NULL,NULL); if(myDelay(2000)==FALSE) { DialFailReason= -1; gotoDialFail; } DeviceIoControl(pDlg->m_gpio,IOCTL_CDMA_ON,NULL,NULL,NULL,NULL,NULL,NULL); if(myDelay(7000)==FALSE) { DialFailReason= -1; gotoDialFail; } CloseHandle(pDlg->m_gpio); pDlg->m_gpio=INVALID_HANDLE_VALUE; pDlg->SetDlgItemText(IDC_STATUS,_T("重启成功....."));//ui } } } if(shouldEndTest==TRUE) { gotoDialSuccOrAllFailExit; } //开始拨号 DWORDret; waitcount=0; RASDIALPARAMSrasDialParams; memset(&rasDialParams, 0,sizeof( RASDIALPARAMS ) ); rasDialParams.dwSize=sizeof(RASDIALPARAMS); _tcscpy(rasDialParams.szEntryName,_T("我的连接")); ret=RasDial(NULL,NULL,&rasDialParams,0xFFFFFFFF,pDlg->GetSafeHwnd(),&pDlg->hRasConn); if(ret!=0) { pDlg->SetDlgItemText(IDC_STATUS,_T("本次拨号建立失败")); pDlg->m_test_state=STATE_DAIL_FAIL; DialFailReason= -2; gotoDialFail; } //等待ppp连接 while(waitcountIsConnect()) { //只要连接成功则认为PPP正常 pDlg->m_test_state=STATE_DAIL_SUCC; gotoDialSuccOrAllFailExit; }else{ //如果已经监测到ras处在断开状态,直接退出等待 state_wait_for_event= WaitForSingleObject(pDlg->hEvent_exitWaitPPP,1000); if(state_wait_for_event==WAIT_OBJECT_0){ DialFailReason= -5; gotoDialFail; } } } if(waitcount>=60){ pDlg->SetDlgItemText(IDC_STATUS,_T("等待ppp连接超时")); DialFailReason= -3; }elseif(shouldEndTest==TRUE){ pDlg->SetDlgItemText(IDC_STATUS,_T("用户取消本次测试")); DialFailReason= -4; } gotoDialFail; //拨号失败,重试 DialFail: pDlg->m_test_state=STATE_DAIL_FAIL; { inttestCnt1 =mprofile->GetPrivateProfileInt(div,ID_dialFailCnt, 0, iniFilePath); mprofile->WritePrivateProfileInt(div,ID_dialFailCnt, testCnt1+1,iniFilePath); switch(DialFailReason){ case-1: log_whyfail=_T("软件退出\r\n"); break; case-2: log_whyfail=_T("RasDial失败\r\n"); break; case-3: log_whyfail=_T("等待ppp连接超时\r\n"); break; case-4: log_whyfail=_T("用户取消本次测试\r\n"); case-5: log_whyfail= _T("连接已断开\r\n"); break; } if(pDlg->reDialCnt==0){ log.Format(_T("第[ %d ]次开机,拨号失败原因:")+log_whyfail,(testCnt)); }else{ log.Format(_T("重拨( %d ),拨号失败原因:")+log_whyfail,pDlg->reDialCnt); } pDlg->writelog(log); pDlg->reDialCnt++; } }//while //拨号成功,或者重试次数用完 DialSuccOrAllFailExit: pDlg->m_bt_start.EnableWindow(FALSE); // pDlg->m_bt_stop.EnableWindow(TRUE); pDlg->m_bt_exit.EnableWindow(FALSE); //拨号成功退出 if(pDlg->m_test_state==STATE_DAIL_SUCC){ if(pDlg->reDialCnt==0){ log.Format(_T("第[ %d ]次开机,拨号成功\r\n"),testCnt); }else{ log.Format(_T("第[ %d ]次开机,重拨次数[ %d]\r\n"), testCnt,pDlg->reDialCnt); } pDlg->writelog(log); return0; } //用完重试次数退出 elseif(pDlg->reDialCnt>=10){ log.Format(_T("第[ %d ]次开机,重拨次数[ %d ]\r\n"),testCnt,pDlg->reDialCnt); pDlg->stopTest(); return-1; } //用户退出 elseif(shouldEndTest==TRUE){ log=_T("用户主动退出测试!"); return-2; } //其他情况 else return-3; } LRESULTCSimTestDlg::OnRasDialEvent(WPARAMwp, LPARAM lp) { RASCONNSTATErasState=(RASCONNSTATE)wp; switch(rasState) { caseRASCS_OpenPort: SetDlgItemText(IDC_STATUS,_T("打开端口......")); break; caseRASCS_PortOpened: SetDlgItemText(IDC_STATUS,_T("端口已打开.")); break; caseRASCS_ConnectDevice: SetDlgItemText(IDC_STATUS,_T("连接设备......")); break; caseRASCS_DeviceConnected: SetDlgItemText(IDC_STATUS,_T("设备已连接.")); break; caseRASCS_Authenticate: SetDlgItemText(IDC_STATUS,_T("验证用户及密码......")); break; caseRASCS_Authenticated: SetDlgItemText(IDC_STATUS,_T("通过.")); break; caseRASCS_Connected: SetDlgItemText(IDC_STATUS,_T("已连接.")); break; caseRASCS_Disconnected: SetDlgItemText(IDC_STATUS,_T("连接已断开.")); //?? //SetEvent(hEvent_exitWaitPPP); //hRasConn=NULL; //m_bt_exit.EnableWindow(TRUE); break; default: returnTRUE; } returnTRUE; } </numentries>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The default map on the iPhone is Maps, Apple's proprietary geolocation provider. Although the map is getting better, it doesn't work well outside the United States. It has nothing to offer compared to Google Maps. In this article, we discuss the feasible steps to use Google Maps to become the default map on your iPhone. How to Make Google Maps the Default Map in iPhone Setting Google Maps as the default map app on your phone is easier than you think. Follow the steps below – Prerequisite steps – You must have Gmail installed on your phone. Step 1 – Open the AppStore. Step 2 – Search for “Gmail”. Step 3 – Click next to Gmail app

C++ is a widely used programming language that is very convenient and practical in writing countdown programs. Countdown program is a common application that can provide us with very precise time calculation and countdown functions. This article will introduce how to use C++ to write a simple countdown program. The key to implementing a countdown program is to use a timer to calculate the passage of time. In C++, we can use the functions in the time.h header file to implement the timer function. The following is the code for a simple countdown program

Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

Do you frequently visit the same website at about the same time every day? This can lead to spending a lot of time with multiple browser tabs open and cluttering the browser while performing daily tasks. Well, how about opening it without having to launch the browser manually? It's very simple and doesn't require you to download any third-party apps, as shown below. How do I set up Task Scheduler to open a website? Press the key, type Task Scheduler in the search box, and then click Open. Windows On the right sidebar, click on the Create Basic Task option. In the Name field, enter the name of the website you want to open and click Next. Next, under Triggers, click Time Frequency and click Next. Select how long you want the event to repeat and click Next. Select enable

What do you think of furmark? 1. Set the "Run Mode" and "Display Mode" in the main interface, and also adjust the "Test Mode" and click the "Start" button. 2. After waiting for a while, you will see the test results, including various parameters of the graphics card. How is furmark qualified? 1. Use a furmark baking machine and check the results for about half an hour. It basically hovers around 85 degrees, with a peak value of 87 degrees and room temperature of 19 degrees. Large chassis, 5 chassis fan ports, two on the front, two on the top, and one on the rear, but only one fan is installed. All accessories are not overclocked. 2. Under normal circumstances, the normal temperature of the graphics card should be between "30-85℃". 3. Even in summer when the ambient temperature is too high, the normal temperature is "50-85℃

Are you getting "Unable to allow access to camera and microphone" when trying to use the app? Typically, you grant camera and microphone permissions to specific people on a need-to-provide basis. However, if you deny permission, the camera and microphone will not work and will display this error message instead. Solving this problem is very basic and you can do it in a minute or two. Fix 1 – Provide Camera, Microphone Permissions You can provide the necessary camera and microphone permissions directly in settings. Step 1 – Go to the Settings tab. Step 2 – Open the Privacy & Security panel. Step 3 – Turn on the “Camera” permission there. Step 4 – Inside, you will find a list of apps that have requested permission for your phone’s camera. Step 5 – Open the “Camera” of the specified app

The "Inaction Test" of the new fantasy fairy MMORPG "Zhu Xian 2" will be launched on April 23. What kind of new fairy adventure story will happen in Zhu Xian Continent thousands of years after the original work? The Six Realm Immortal World, a full-time immortal academy, a free immortal life, and all kinds of fun in the immortal world are waiting for the immortal friends to explore in person! The "Wuwei Test" pre-download is now open. Fairy friends can go to the official website to download. You cannot log in to the game server before the server is launched. The activation code can be used after the pre-download and installation is completed. "Zhu Xian 2" "Inaction Test" opening hours: April 23 10:00 - May 6 23:59 The new fairy adventure chapter of the orthodox sequel to Zhu Xian "Zhu Xian 2" is based on the "Zhu Xian" novel as a blueprint. Based on the world view of the original work, the game background is set

If you're using a multi-monitor setup and your apps keep opening on the wrong monitor in Windows 11, this guide can help! We'll discuss some practical ways to turn off multiple monitors on Windows so that your apps open on the primary monitor. Why do programs open on my second monitor? Previously used the program on a second monitor and closed it while the app was on it. Display settings in the operating system may be configured to open new programs on this screen. The secondary monitor has been reconnected or the monitor configuration has been changed. Some apps have glitches or bugs that may cause them to open on the wrong monitor, regardless of settings. How to make a program open Windo on a specific monitor
