How to automatically run the application after Windows XP is started

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.