Customized boot self-starting program under WinCE

Source: Internet
Author: User

Customized boot self-starting program under WinCE

I checked it online and found that there are still a lot of related posts. recently, due to the company's project needs, I made a simple program to try this function. it is not feasible to use many methods on the Internet. It is estimated that it should be usable in the first place. Then everyone reposted each other and transferred some items to another place, which may be missing or wrong, this is because few people have actually tested it. I have organized the entire process based on my actual tests and explained the principle of some steps here.

Assume that the application is:

Method 1: The main idea is to add the application and its shortcut to the image, and then add the shortcut to the startup directory, so that the application can run automatically after the system runs. This method does not cover Windows desktop, but only loads an application at startup.


1. Ensure that the original project file can be compiled successfully. And the kernel image can run.

2 create a shortcut file with the following content: 10 # "\ windows \" (note that the quotation marks must be required) the number of all characters after the Chinese herbal medicine 10 #, including quotation marks, modify the name of your application. (If you have tried this number, even if it is not the number of characters after #, it can be started normally. I don't understand it.) copy the file and the directory to which xxx_relase is located (the directory ).

3. Modify the file in Pb and add it in the files section (the files section can contain executable files not executed locally): $ (_ flatreleasedir) \ nk h $ (_ flatreleasedir) \ nk h (Note: $ (_ flatreleasedir) indicates the xxx_relase folder; h after NK indicates that the file to be added is a hidden attribute)

4. Add the shortcut to the startup directory, specifically: Modify the project file and add the following content: Directory ("\ windows \ Startup"):-file ("", "\ windows \") because the wince ROM image places all files in the Windows directory by default, some files must be moved to a specific location during system boot ,. the DAT file can be moved. for example, the above step is to move the instance located in Windows to Windows \ Startup. the startup directory determines that the program can be started by itself.

5. Go to the build OS menu, select build and sysgen (clean before buiding to be checked), and the compilation is complete, there will be an error message indicating that you did not find it on your disk (because we chose clean before building during compilation, and the files originally placed in the xxx_relase directory were all cleaned ). copy the and file to the xxx_relase folder again and then makeimage it. in this way, the application is written into the kernel (under the Windows directory ). write the generated or burned into flash, so that you can see that your application is self-started. at this point, someone may ask, since it will be cleaned up during compilation, the second step does not need to be copied first, but will be copied again in the fifth step? I also thought about this problem, but the actual test found that the two files and the file are not written into the kernel (the file cannot be found in windows after the system is started ). the bib and DAT files are both used in the make image stage. There is no reason to see this problem. this question cannot be answered.

Method 2: add the application to the image and use your application to directly replace the wince desktop program. In this way, your application is actually used as the shell of wince.


1. First, execute 1 ~ of method 1 ~ In step 3, the application is burned into the kernel.

2. go to the build OS menu and select build and sysgen (clean before buiding should be checked. If it is not checked here, the compiled kernel may not run). The compilation is complete, there will be an error message indicating that you did not find it on your disk (because we chose clean before building during compilation, and the files originally placed in the xxx_relase directory were all cleaned ). copy the file and file to the xxx_relase folder again and modify the file. (If the file cannot be found in Pb, you can find it in the xxx_relase folder ): [HKEY_LOCAL_MACHINE \ init] "launch50" = "depend50" = HEX: 14,00, 1e, 00 change this to your application (for example :). When the wince system is started, it will execute launchxx sequentially, XX is a decimal number, dependxx indicates that before the current application is running, launch20 (hexadecimal is 14 ), lanuch30 (The hexadecimal format is 1E) must be run first. open to see. lanuch20 corresponds to launch30. our own shell should run properly after the two processes are loaded. in addition, there is a section in the wince help document: This function must be called by all applications that the kernel starts at startup throughHKEY_LOCAL_MACHINE \ initRegistry key.

It seems that the signalstarted function should be added to our source program. for the MFC program, we can go before the return of initinstance. add this line of code signalstarted (_ wtol (getcommandline (). In fact, if an application needs to be loaded from init, there must be a unicode string as a command line parameter, this parameter is converted to an integer and then passed to the signalstarted function. this method is used to notify the operating system that it has finished running. we recommend that you add the signalstarted function to any application started through init.

3. makeimage: Write the generated data to flash, so that you can see that your application is self-started. in addition, Windows desktop programs won't be started. Your program is Windows shell, but there is a problem, that is, when you close the application, the machine will crash due to the loss of the original wince desktop program.

Method 3: add the application to the image and modify the Registry to enable the application. This will not replace the Windows desktop program, but let windows load your application like a desktop program. The effect is the same as that in method 1.

This is the same as method 2. It is slightly different: Add the following statement under [HKEY_LOCAL_MACHINE \ init] in the file: "launch80" = "" depend80 "= HEX: 1E, the difference between 00 and method 2 is that it has not been replaced.

Of course, the premise of the preceding three methods is that your program can run normally in the kernel compiled by the current Pb project. this sentence seems nonsense, but it is very important. when I was debugging, the program couldn't start at one time. I always thought that the Registry or bib file had an error and it couldn't work after a long time. finally, I found that this application was compiled in the previous SDK and cannot be run in the current system. so I re-compiled a new SDK under the available system to solve the problem.

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: 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.