I wrote another program, such as shellexe.exe, to add this program to the image, call shellexe using the startup shortcut, and then call the application in the SD card using shellexe. The specific implementation steps are as follows: 1. Compile the following code under EVC:Generate the executable file of shellexe.exe. The main function of this code segment is to find the specified application and execute it. The following Code ensures that the application is executed only after the SD card file system is correctly loaded;
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow){WIN32_FIND_DATA fd;HANDLE hd=INVALID_HANDLE_VALUE;int iCount = 20;while(iCount--){hd=::FindFirstFile(lpCmdLine,&fd);Sleep(500);if(INVALID_HANDLE_VALUE!=hd) break;}if(0==iCount) return 0;FindClose(hd);SHELLEXECUTEINFO ShExeInfo={0};ShExeInfo.cbSize=sizeof(SHELLEXECUTEINFO);ShExeInfo.fMask=SEE_MASK_NOCLOSEPROCESS;ShExeInfo.hwnd=NULL;ShExeInfo.lpVerb=NULL;ShExeInfo.lpFile=lpCmdLine;ShExeInfo.lpParameters=L"";ShExeInfo.lpDirectory=NULL;ShExeInfo.nShow=SW_SHOW;ShExeInfo.hInstApp=NULL;ShellExecuteEx(&ShExeInfo);return 0;}
while(iCount--){hd=::FindFirstFile(lpCmdLine,&fd);Sleep(500);if(INVALID_HANDLE_VALUE!=hd) break;}
The file name and path are specified by the command line parameters:
ShExeInfo.lpFile=lpCmdLine;
2. Create a shortcut, such as Autorun. lnk, and edit the content as follows:
21#\windows\shellexe.exe \stdcard\MyApp.exe
The absolute path of the \ stdcard \ myapp.exe application;
3. Add myapp.exe and autorun. lnk to NK by adding the following content to the project. bib file:
ShellExe.exe f:\WINCE420\PBWORKSPACES\LioetEnTer\RelDir\ShellExe.exe NK SAutorun.lnk f:\WINCE420\PBWORKSPACES\LioetEnTer\RelDir\Autorun.lnk NK S
Note: the attribute of shellexe.exe cannot contain H (hidden ).
4. Add the following content to project. DAT:
Directory("\Windows\Startup"):-File("Autorun.lnk","\Windows\Autorun.lnk")
5. Select make image (((of course, buildcan also be used. Click "Flash" and run the program. You can see that the myapp.exe file of the SDK is correctly executed.
Summary
This scheme is convenient to use. shellexe.exe does not need to be re-compiled every time. You only need to modify Autorun. lnk according to the application path, and can load applications in flash, USB flash drive, and SD card. You do not need to re-run the kernel after debugging and upgrading the application.