首页 » 技术分享 » 一键升级 ME860 CWM recovery

一键升级 ME860 CWM recovery

 

      最近看到Android 手机用户,不知道怎么升级CWM,故此写了一个升级的工具.

 首先看看升级CWM的步骤。

1. 先要现在对应recovery.img, 这个地方就是http://www.clockworkmod.com/rommanager

2. 现在fastboot 工具包,随便搜索一下。

3. 使用命令 fastboot  flash recovery  recovery.img  就可以了,只要保证这些文件在同一个目录下,但是刷机之前,一定要进入fastboot 模式。

将这些写入一个window 程序那么就如下:

1. 启动一个进程。

BOOL LaunchProcess(CString &strCmd,  CString& strWorkPath, BOOL bShow = FALSE, BOOL bWait = FALSE )
{
	LPCTSTR lpWorkPath = NULL;
	if ( !strWorkPath.IsEmpty() )
	{
		lpWorkPath = strWorkPath.GetBuffer( strWorkPath.GetLength() );
	}

	STARTUPINFO StartInfo = { sizeof(StartInfo)};
    StartInfo.dwFlags = STARTF_USESHOWWINDOW;
	StartInfo.wShowWindow = SW_HIDE;
	if ( bShow )
	{
		StartInfo.wShowWindow = SW_SHOW;
	}

	PROCESS_INFORMATION PiThis = {0};
	BOOL bRetCode = CreateProcess(
		NULL,
		strCmd.GetBuffer( strCmd.GetLength() ),
		NULL,
		NULL,
		FALSE,
		0,
		NULL,
		lpWorkPath,
		&StartInfo,
		&PiThis);
	if ( !bRetCode )
	{
		return FALSE;
	}
 
	strCmd.ReleaseBuffer();
	if (!strWorkPath.IsEmpty())
	{
		strWorkPath.ReleaseBuffer();
	}

	if ( bWait )
	{
		WaitForSingleObject( PiThis.hProcess, -1);
	}
	
	DWORD dwCode = 0;
	GetExitCodeProcess(PiThis.hProcess, &dwCode);

	CloseHandle( PiThis.hProcess );
	CloseHandle( PiThis.hThread );

	if ( dwCode == 0 )
	{
		return TRUE;
	}

	return FALSE;
}

2. 从资源中将文件释放出来

BOOL ReleaseFile( CString strFileName, UINT uID )
{
	HRSRC hResource = FindResource( NULL, MAKEINTRESOURCE(uID), _T("EXE"));
	DWORD dwSize = SizeofResource( NULL, hResource );
	HGLOBAL hGlobal = LoadResource( NULL, hResource );
	LPVOID pBuffer = LockResource( hGlobal );
	CAtlFile TheOutFile;
	TheOutFile.Create( strFileName, GENERIC_WRITE, FILE_SHARE_READ| FILE_SHARE_WRITE,
		CREATE_ALWAYS);
	TheOutFile.Write(pBuffer, dwSize);
	TheOutFile.Close();

	return TRUE;
}

真正的过程

ReleaseFile( m_strFastBoot, IDR_EXE_FASTBOOT );
	ReleaseFile( m_strImg, IDR_EXEIMG );
	BOOL bRetCode = LaunchProcess( m_strCmd, m_strWorkPath, FALSE, TRUE );
	DeleteFiles();
	if ( bRetCode )
	{
		AfxMessageBox(_T("CWM  更新成功!"));
	}
	else
	{
		AfxMessageBox(_T("过程中有错误,请再来一次!"), MB_OK | MB_ICONERROR);
	}

该工具的位置在http://download.csdn.net/detail/zwh37333/4279271

转载自原文链接, 如需删除请联系管理员。

原文链接:一键升级 ME860 CWM recovery,转载请注明来源!

0