|
做过一个开机自动运行程序的例子,不知对楼主有帮助没,升级的话,把NandFlash下的Exe替换为新的exe即可。win32程序,代码如下:
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
WIN32_FIND_DATA fd;
LPTSTR sourceFilePath = _T("\\NandFlash\\APPLICATION\\RH701.exe");
LPTSTR exitFilePath = _T("\\RH701.exe");
HANDLE hd=INVALID_HANDLE_VALUE;
int iCount = 20;
while(iCount--) //等待加载NANDFLASH 成功
{
hd=::FindFirstFile(_T("\\NandFlash\\*.*"),&fd);
Sleep(100);
if(INVALID_HANDLE_VALUE!=hd) break;
}
FindClose(hd);
hd=::FindFirstFile(sourceFilePath,&fd);
if(hd!=INVALID_HANDLE_VALUE)
{
CopyFile(sourceFilePath,exitFilePath,FALSE);//目标文件已存在则覆盖目标文件
//DeleteFile(sourceFilePath);
}
FindClose(hd);
SHELLEXECUTEINFO ShExeInfo={0};
ShExeInfo.cbSize=sizeof(SHELLEXECUTEINFO);
ShExeInfo.fMask=SEE_MASK_NOCLOSEPROCESS;
ShExeInfo.hwnd=NULL;
ShExeInfo.lpVerb=NULL;
ShExeInfo.lpFile=exitFilePath;
ShExeInfo.lpParameters=L"";
ShExeInfo.lpDirectory=NULL;
ShExeInfo.nShow=SW_SHOW;
ShExeInfo.hInstApp=NULL;
ShellExecuteEx(&ShExeInfo);
return 0;
} |
|