⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mobiletool.cpp

📁 Mobile平台下GPRS上网连接方式
💻 CPP
📖 第 1 页 / 共 3 页
字号:

//将图形输出到屏幕上(有点像BitBlt) 
bResult=pPic->Render(hDC_Temp,0,0,nScrWidth,nScrHeight, 
0,hmHeight,hmWidth,-hmHeight,NULL); 

pPic->Release(); 
::GlobalFree(hGlobal);
//delete pPic;

CloseHandle(hFile);//关闭打开的文件 

if (SUCCEEDED(bResult)) 
{ 
return S_OK; 
} 
else 
{ 
return E_FAIL; 
} 
}
//*/

void ZMExit()
{
	if( ZMGStatus::GetInst()->GetFenduIni()->IsFirstInstall == 0 )
	{
	  ZMGStatus::GetInst()->GetFenduIni()->IsFirstInstall = 1;
	  ZMGStatus::GetInst()->WriteFenduIni(); 
	}
	DebugPrint("清理过期rss文件...\r\n");
	ZMPath rssPath(ZMPath::CARD_PATH,TEXT("rss"));
	ZMFile::DelDirectory(rssPath.GetFileName(),10);
	DebugPrint("清理过期pic文件...\r\n");
	ZMPath picPath(ZMPath::CARD_PATH,TEXT("save"));
	picPath.AddChildPath(TEXT("pic"));
	ZMFile::DelDirectory(picPath.GetFileName(),20);
	DebugPrint("清理完毕!\r\n");
	ZMCommTransaction::GetInst()->SetList2File(ZMFenDu::GetInst()->GetLoadList(), LOAD_LIST);
	//com uninit
	CoUninitialize();
	::PostMessage(g_hwnd,WM_QUIT,0,0);
}
/*
void SetTimer(uint32 nIDEvent,uint32 uElapse,TIMERPROC lpTimerFunc)
{
SetTimer(NULL, nIDEvent,uElapse,lpTimerFunc); 
}
*/
void SetTimer(uint32 nIDEvent,uint32 uElapse)
{
	SetTimer(NULL, nIDEvent,uElapse,clockFunction); 
}

void StartTimer(uint32 nIDEvent,uint32 uElapse)
{
	SetTimer(NULL, nIDEvent,uElapse,clockFunction); 
}
void STopTimer(uint32 uID)
{
	KillTimer(NULL,uID);
}

void KillTimer(uint32 uID)
{
	KillTimer(NULL,uID);
}

void CALLBACK /*ZMMainMenu::*/clockFunction(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
{
	ZMTIME time = ZMFile::ZMGetLocalTime();
	ZMMSG msg;
	msg.message = ZM_TIMER_MSG;
	msg.lParam = time.wHour;
	msg.wParam = time.wMinute;
	ZMGStatus::GetInst()->UpdateTimeInfo(msg);	

#ifdef AMOI_TIMER
	if( GetXiaXinTime() && ZMFile::GetTime() - GetXiaXinTime() >10*60*1000)
	{
		ZMGStatus::GetInst()->SetXiaXinTimer();
	}
#endif
}

/*
void CALLBACK clockFuncComotize(HWND hwnd , UINT uMsg , UINT idEvent, DWORD dwTime)
{
ZMTIME time = ZMFile::ZMGetLocalTime();
CustomizePerSon::GetInst()->SetTime(time.wHour,time.wMinute);
}
*/
char * strdup(const char *s)
{
	char *t = NULL;
	if (s && (t = (char*)malloc(strlen(s) + 1)))
		strcpy(t, s);
	return t;
} 

//查找在SAVE目录下的杂志,为避免和手机下载的杂志混合,所以只搜索SAVE下面的,不搜索子目录
//ZMFenDu::GetInst()->GetSearchList()->DeleteList()必须自已调用清调空间,
//否则内存泄露,这里在重新写链表前要DELETE一次,程序退出前也要清除

void FindDownLoadMag()
{
	
	WIN32_FIND_DATA FileData;   // Data structure describes the file found
	HANDLE hSearch;             // Search handle returned by FindFirstFile
	
	memset(&FileData,0,sizeof(FileData));
	 
	 BOOL bFinished = TRUE;
	 //开始在tmp目录下查找.hmag

	 wchar afileName[256]={0};
	 wchar atempFileName[256] = {0};
	 ZMUserInfo::GetInst()->GetFullPathFileName(
		 ZMPath::CARD_PATH,ZMUserInfo::ZM_PATH_SAVE_MAG,TEXT("*.hmag"),afileName,ZMREAD);

	 hSearch = FindFirstFile (afileName, &FileData);

       //先把之前的内存清掉
		//清空列表
		uint16 listLen = ZMFenDu::GetInst()->GetSearchList()->Length();
		for( int i = 0;i<listLen;i++ )
		{
			_LOCAL_MAG_INFO *LocalMag = (_LOCAL_MAG_INFO *)ZMFenDu::GetInst()->GetSearchList()->Value(i);
			delete []LocalMag->m_FileName;
			delete []LocalMag->m_Path;
		}
		ZMFenDu::GetInst()->GetSearchList()->DeleteList();

	 if (hSearch == INVALID_HANDLE_VALUE)
	 {
	 }
	 else
	 {
		 LPLOCAL_MAG_INFO LocalMag = new LOCAL_MAG_INFO();
		 wchar  Path[128] = {0};
		  ZMUserInfo::GetInst()->GetFullPathFileName(
			  ZMPath::CARD_PATH,ZMUserInfo::ZM_PATH_SAVE_MAG,FileData.cFileName,Path,ZMREAD); //把路径写进LIST
		 
		  ZMFile  file;
		  BOOL b = file.open(Path,ZMFile::ZM_OPEN_R_EXIST,ZMFile::ZM_SHARE_RW);
		  if( b ) //读取杂志ID
		  {
			  file.seek(4,ZMFile::ZMFILE_SEEK_BEGIN); //跳过4个字节
			  file.read((int8 *)&LocalMag->m_MagID,4); //读取
		  }
		  file.close();

		  int32 Len = zmstrlen(Path);
		  LocalMag->m_Path = new wchar[Len+1];
		  memset(LocalMag->m_Path,0,sizeof(wchar)*(Len+1));
		  zmstrcpy(LocalMag->m_Path,Path);

		  Len = zmstrlen(FileData.cFileName);
		  LocalMag->m_FileName = new wchar[Len+1];
		  memset(LocalMag->m_FileName,0,sizeof(wchar)*(Len+1));
		  //zmstrcpy(LocalMag->m_FileName,FileData.cFileName); //把文件名写进LIST
		  zmstrcatlen(LocalMag->m_FileName,FileData.cFileName,Len - 5); 

		
		 ZMFenDu::GetInst()->GetSearchList()->Append(LocalMag);
		 while( bFinished )
		 {
			if( FindNextFile(hSearch, &FileData)) 
			{
				 LPLOCAL_MAG_INFO LocalMag = new LOCAL_MAG_INFO();

				 wchar  Path[128] = {0};
				   ZMUserInfo::GetInst()->GetFullPathFileName(
			  ZMPath::CARD_PATH,ZMUserInfo::ZM_PATH_SAVE_MAG,FileData.cFileName,Path,ZMREAD);

			  ZMFile  file;
			  BOOL b = file.open(Path,ZMFile::ZM_OPEN_R_EXIST,ZMFile::ZM_SHARE_RW);
			  if( b ) //读取杂志ID
			  {
				  file.seek(4,ZMFile::ZMFILE_SEEK_BEGIN); //跳过4个字节
				  file.read((int8 *)&LocalMag->m_MagID,4); //读取
			  }
			  file.close();

			  int32 Len = zmstrlen(Path);
			  LocalMag->m_Path = new wchar[Len+1];
			  memset(LocalMag->m_Path,0,sizeof(wchar)*(Len+1));
			  zmstrcpy(LocalMag->m_Path,Path);

			  Len = zmstrlen(FileData.cFileName);
			  LocalMag->m_FileName = new wchar[Len+1];
			  memset(LocalMag->m_FileName,0,sizeof(wchar)*(Len+1));
			  //zmstrcpy(LocalMag->m_FileName,FileData.cFileName); //把文件名写进LIST
			  zmstrcatlen(LocalMag->m_FileName,FileData.cFileName,Len - 5); 


               //zmstrcpy(LocalMag->m_FileName,FileData.cFileName); //把文件名写进LIST

				 ZMFenDu::GetInst()->GetSearchList()->Append(LocalMag);
			}
			else
			{
				bFinished = FALSE;
			}
		 }

	 }

	 //搜索手机的
	 FindDownLoadMagModule(afileName);
}

void FindDownLoadMagModule(wchar *path)
{
	WIN32_FIND_DATA FileData;   // Data structure describes the file found
	 HANDLE hSearch;             // Search handle returned by FindFirstFile
	
	memset(&FileData,0,sizeof(FileData));
	 
	 BOOL bFinished = TRUE;
	 //开始在tmp目录下查找.hmag

	 wchar afileName[256]={0};
	 wchar atempFileName[256] = {0};
	 ZMUserInfo::GetInst()->GetFullPathFileName(
		 ZMPath::MOBILE_PATH,ZMUserInfo::ZM_PATH_SAVE_MAG,TEXT("*.hmag"),afileName,ZMREAD);//手机路径

	 BOOL IsSamePath = zmstrcmp(path,afileName); //比较两个路径,是否一样

	 if( IsSamePath ) //如果是一样的,不用继续搜索,直接返回
		 return;

	 hSearch = FindFirstFile (afileName, &FileData);

       //不要把链表清掉,而是要把手机和卡的杂志合在一起

	// ZMFenDu::GetInst()->GetSearchList()->DeleteList();
	 

	 if (hSearch == INVALID_HANDLE_VALUE)
	 {
	 }
	 else
	 {
		 LPLOCAL_MAG_INFO LocalMag = new LOCAL_MAG_INFO();
		 wchar  Path[128] = {0};
		  ZMUserInfo::GetInst()->GetFullPathFileName(
			  ZMPath::MOBILE_PATH,ZMUserInfo::ZM_PATH_SAVE_MAG,FileData.cFileName,Path,ZMREAD); //把路径写进LIST
		
		  ZMFile  file;
		  BOOL b = file.open(Path,ZMFile::ZM_OPEN_R_EXIST,ZMFile::ZM_SHARE_RW);
		  if( b ) //读取杂志ID
		  {
			  file.seek(4,ZMFile::ZMFILE_SEEK_BEGIN); //跳过4个字节
			  file.read((int8 *)&LocalMag->m_MagID,4); //读取
		  }
		  file.close();

		  int32 Len = zmstrlen(Path);
		  LocalMag->m_Path = new wchar[Len+1];
		  memset(LocalMag->m_Path,0,sizeof(wchar)*(Len+1));
		  zmstrcpy(LocalMag->m_Path,Path);

		  Len = zmstrlen(FileData.cFileName);
		  LocalMag->m_FileName = new wchar[Len+1];
		  memset(LocalMag->m_FileName,0,sizeof(wchar)*(Len+1));
		 // zmstrcpy(LocalMag->m_FileName,FileData.cFileName); //把文件名写进LIST
		  zmstrcatlen(LocalMag->m_FileName,FileData.cFileName,Len - 5); 

		
		
		 ZMFenDu::GetInst()->GetSearchList()->Append(LocalMag);
		 while( bFinished )
		 {
			if( FindNextFile(hSearch, &FileData)) 
			{
				 LPLOCAL_MAG_INFO LocalMag = new LOCAL_MAG_INFO();

				 wchar  Path[128] = {0};
				   ZMUserInfo::GetInst()->GetFullPathFileName(
			  ZMPath::MOBILE_PATH,ZMUserInfo::ZM_PATH_SAVE_MAG,FileData.cFileName,Path,ZMREAD);

			  ZMFile  file;
			  BOOL b = file.open(Path,ZMFile::ZM_OPEN_R_EXIST,ZMFile::ZM_SHARE_RW);
			  if( b ) //读取杂志ID
			  {
				  file.seek(4,ZMFile::ZMFILE_SEEK_BEGIN); //跳过4个字节
				  file.read((int8 *)&LocalMag->m_MagID,4); //读取
			  }
			  file.close();

			  int32 Len = zmstrlen(Path);
			  LocalMag->m_Path = new wchar[Len+1];
			  memset(LocalMag->m_Path,0,sizeof(wchar)*(Len+1));
			  zmstrcpy(LocalMag->m_Path,Path);

			  Len = zmstrlen(FileData.cFileName);
			  LocalMag->m_FileName = new wchar[Len+1];
			  memset(LocalMag->m_FileName,0,sizeof(wchar)*(Len+1));
			 // zmstrcpy(LocalMag->m_FileName,FileData.cFileName); //把文件名写进LIST
			   zmstrcatlen(LocalMag->m_FileName,FileData.cFileName,Len - 5); 


               //zmstrcpy(LocalMag->m_FileName,FileData.cFileName); //把文件名写进LIST

				 ZMFenDu::GetInst()->GetSearchList()->Append(LocalMag);
			}
			else
			{
				bFinished = FALSE;
			}
		 }

	 }
}

//查找储存卡extern HWND g_hwnd;

void FindCardPath(void)
{
	WIN32_FIND_DATA wfd;
	memset(&wfd,0,sizeof(WIN32_FIND_DATA));
	uint64 iFreeBytesToCaller1=0, iTotalBytes1=0, iFreeBytes1=0;
	uint64 iFreeBytesToCaller2=0, iTotalBytes2=0, iFreeBytes2=0;

	HANDLE ha = FindFirstFlashCard(&wfd);
	if(ha!=INVALID_HANDLE_VALUE)
	{
		//::MessageBoxW(g_hwnd,L"找到FirstFlashCard",L"",0);
		ZMFile file;
		wchar pathFile[256]={0};
		wchar *pCardPath1 = NULL;
		wchar *pCardPath2 = NULL;
		if(zmstrlen(wfd.cFileName)>0)
		{
			//::MessageBoxW(g_hwnd,L"(wfd.cFileName)>0",L"",0);
			pCardPath1 = new wchar[MAX_FILE_NAME_LEN];
			memset((int8*)pCardPath1,0,sizeof(wchar)*MAX_FILE_NAME_LEN);

			zmstrcpy(pCardPath1,wfd.cFileName);
			zmstrcpy(pathFile,wfd.cFileName);
			zmstrcat(pathFile,TEXT("\\card.txt"));
			
			if(file.open(pathFile, ZMFile::ZM_CREATE_W))
			{
				//::MessageBoxW(g_hwnd,L"能读写",L"",0);
				file.close();
				ZMFile::DelFile(pathFile);
				GetDiskFreeSpaceEx(pCardPath1,(PULARGE_INTEGER)&iFreeBytesToCaller1, 
					(PULARGE_INTEGER)&iTotalBytes1, (PULARGE_INTEGER)&iFreeBytes1);
			}
			else
			{
				BUF_DELETE(pCardPath1);
			}
		}

		if(FindNextFlashCard(ha,&wfd))
		{
			//::MessageBoxW(g_hwnd,L"找到NextFlashCard",L"",0);
			if(zmstrlen(wfd.cFileName)>0)
			{
				//::MessageBoxW(g_hwnd,L"(wfd.cFileName)>0",L"",0);
				pCardPath2 = new wchar[MAX_FILE_NAME_LEN];
				memset((int8*)pCardPath2,0,sizeof(wchar)*MAX_FILE_NAME_LEN);
				zmstrcpy(pCardPath2,wfd.cFileName);
				zmstrcpy(pathFile,wfd.cFileName);
				zmstrcat(pathFile,TEXT("\\card.txt")); 
				
				if(file.open(pathFile, ZMFile::ZM_CREATE_W))
				{
					//::MessageBoxW(g_hwnd,L"能读写",L"能读写",0);
					file.close();
					ZMFile::DelFile(pathFile);

					GetDiskFreeSpaceEx(pCardPath2,(PULARGE_INTEGER)&iFreeBytesToCaller2, 
						(PULARGE_INTEGER)&iTotalBytes2, (PULARGE_INTEGER)&iFreeBytes2);
				}
				else
				{
					BUF_DELETE(pCardPath2);
				}
			}
		}
		if(iTotalBytes2>iTotalBytes1)
		{
			//::MessageBoxW(g_hwnd,L"SetSDCardPath(pCardPath2)",L"",0);
			SetSDCardPath(pCardPath2);
			BUF_DELETE(pCardPath1);
		}
		else
		{
			//::MessageBoxW(g_hwnd,L"SetSDCardPath(pCardPath1)",L"",0);
			SetSDCardPath(pCardPath1);
			BUF_DELETE(pCardPath2);
		}
	}
}

void BrowserOpenURL(const wchar* pszURL)
{
	SHELLEXECUTEINFO  info;
	memset(&info, 0, sizeof(SHELLEXECUTEINFO));
	info.cbSize = sizeof(SHELLEXECUTEINFO);
	info.fMask = SEE_MASK_NOCLOSEPROCESS;
	info.hwnd = NULL;
	info.lpVerb = L"Open";
	info.lpFile = L"\\windows\\iexplore.exe";
	info.lpParameters = pszURL;
	info.lpDirectory = NULL;
	info.nShow = SW_SHOWNORMAL;
	
	ShellExecuteEx(&info);
}

BOOL GetInstallFileName( wchar *pFileName )
{
	zmstrcpy( pFileName, L"update.cab" );
	return TRUE;
}
BOOL InstallFromFile( const wchar *pFileFullName )
{
	//**********************************test(PQH 2008-05-29************************

	  if( ZMGStatus::GetInst()->GetFenduIni()->IsFirstInstall == 0 )
	  {
		     ::MessageBox(g_hwnd, TEXT("请重新启动,再更新版本!"), NULL, MB_OK | MB_ICONERROR);
			 ZMExit();
			 return FALSE;
	  }

	
	CloseHandle(g_hwnd);
	CloseHandle(g_hWndMenuBar);
	 ZMExit();

	 ZMFile file;
	 if( !file.open((wchar*)pFileFullName,ZMFile::ZM_OPEN_R_EXIST) )
	 {
		  ::MessageBox(NULL, TEXT("安装文件不存在!"), NULL, MB_OK | MB_ICONERROR);
		 return FALSE;
	 }

	  SHELLEXECUTEINFO   execInf;   
	  ZeroMemory   (&execInf,   sizeof   (execInf));     
	  execInf.cbSize   =   sizeof   (execInf);     
	  execInf.fMask   =   SEE_MASK_NOCLOSEPROCESS;     
	  execInf.lpFile   =   (wchar*)pFileFullName; 
	  execInf.lpVerb   =   TEXT("open");   
	 
	  if( ShellExecuteEx(&execInf) )  //成功了
	  {
		 
	  }
	  else  //失败
	  {
		  //ZMExit();
		  return FALSE;
	  }

	  /*if(execInf.hProcess)   
	  {
		 WaitForSingleObject(execInf.hProcess,INFINITE);
		 CloseHandle(execInf.hProcess);  
	  }*/

    //**********************************************test end****************************
	 // ZMExit();
	return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -