Windows CE下开机自动运行程序

 
How to Configure the Registry to Run an Application at Startup
You can add an application to your OS design and then configure the registry to run the application when your run-time image boots.
By doing so, you can decrease the amount of time involved in debugging an application. Otherwise, after your run-time image boots, you must manually load and run the application on your target device.
Note   This procedure requires you to have already created an application. For information about creating and building an application in the context of using Platform Builder with a CEPC, see Tutorial: Building a Run-Time Image for a CEPC.
To track your progress, select the check box next to each step.
 
Step
Topic
1. Open an existing OS design, or create a new one, and then build and download the run-time image to a target device.
2. Use the Remote Registry Editor to discover the HKEY_LOCAL_MACHINE/Init launch numbers for each .exe file that runs on the target device at startup.
To run your application at startup, assign launch numbers to your application's .exe files in the HKEY_LOCAL_MACHINE/Init section of the registry of the target device.
  • Connect to your target device using the Remote Registry Editor.
If the connection fails, see Configuring the Connection to a Target Device Using Platform Manager.
  • In the Windows CE Remote Registry Editor window, expand the Default Device node, then the HKEY_LOCAL_MACHINE node, and then the Init node.
  • In the right pane, in the Name column, note the launch number for each application.
These numbers use the launch nn format, where nn is the launch number.
Opening Remote Registry Editor
Connecting to a Target Device with a Remote Tool
3. Add the application to your OS design as a project.
4. Create a registry entry in the HKEY_LOCAL_MACHINE/Init section of the Project.reg file for your application.
5. Build the changed Catalog items in your OS design.
6. Configure a connection between your development workstation and your target device.
Note   Debugging is not necessary at this point.
If your target device is a CEPC, boot your run-time image on the CEPC.
For more information, see How to Configure and Download a Run-Time Image to a CEPC.
If your target device is the Emulator, download your run-time image to the Emulator.
For more information, see Downloading a Run-Time Image to the Emulator.
Configuring a Connection for Downloading and Debugging
7. When the download process is complete, verify that the application launched properly on your target device.
The time required to display the OS depends on the size of the downloaded run-time image.
Not applicable
 Configuring a Registry File to Run an Application at Startup
You can configure a registry (.reg) file to run a module when your run-time image starts up. There are two ways to configure registry files:
  • Modify the registry file before building and downloading the run-time image.
  • Use the Remote Registry Editor after downloading the run-time image to the device.
Using the Remote Registry Editor changes the run-time image registry, but the changes are not persisted to the registry files in Platform Builder. The next time you download the run-time image, you must configure the registry again.
For more information, see Remote Registry Editor.
To modify a registry file in the IDE
  1. From the Workspace window, choose the ParameterView tab at the bottom of the window.
  2. Expand the nodes until you find the folder for the target device you have chosen.
For example, if you create an OS design for the Emulator, find the Emulator folder.
  1. Expand the folder and then expand the Project Specific Files folder.
  2. Select and open the appropriate registry file.
Typically, this is the Project.reg file. Settings in Project.reg override other registry settings due to the order in which the build system processes the registry files.
  1. Update or add the HKEY_LOCAL_MACHINE/Init section of the registry file with the following code.
6.     [HKEY_LOCAL_MACHINE/Init]
7.     "launchnn"="defined_module_name"
"dependnn"=hex:xx,yy...
The following table shows descriptions of the parameters in the code you must update or add to the HKEY_LOCAL_MACHINE/Init section of the registry file.
Parameter
Description
launch nn
Defines the order that the module is started in, where nn is 00–99.
Enclose this parameter in double quotation marks (" ").
defined_module_name
Specifies the name of the module to be started.
Enclose this parameter in double quotation marks (" ").
depend nn
Optional. Assigns a dependency that prevents the defined module from starting until another module is started, where nn is 00–99.
Enclose this parameter in double quotation marks (" ").
hex: xx,yy...
Defines the hexadecimal number of the module that must be run before the defined module is run.
This parameter consists of the hex keyword, a colon, and one or more hexadecimal numbers, one for each byte of hexadecimal data.
After your run-time image calls a module using the Init registry value, the application must call the SignalStarted function.
SignalStarted indicates that the module is ready for the rest of the OS to continue processing.
The value passed as the parameter to SignalStarted is the value passed on the command line of the module started from the Init key.
  1. If you do not know the hexadecimal numbers for the module dependencies that your application requires, open and search Common.reg for the module names.
The following code example shows how to set your module to depend on the standard initialization modules, which include Filesys.exe, Gwes.exe, Device.exe, and Explorer.exe.
[HKEY_LOCAL_MACHINE/Init]
"launchnn"="defined_exe_name"
"dependnn"=hex:0A,00,14,00,1E,00,32,00
  1. Save and close the registry file.

You have successfully modified a registry file to run a module at startup. 

以上方法是要通赤修改注册表来实现,对于用户来说,可能不方便,那么,我们能不能使Windows CE启动完成后自动运行Flash Disk上某个目录下的所的.exe文件呢,请看下面的:

在Windows CE 的Windows 目录下,有一个StartUp文件夹,在Windows CE启动完成后,Windows CE会自动运行这个文件夹下的所有.ExE文件,但这个目录下的所有内容在断电后会丢失,还是不能完成上电自动运行,那么我们能不能把这个目录改到Flash Disk上的某个目录下去呢,答案是肯定的,而且非常容易,我们只要修改注册表

[HKEY_LOCAL_MACHINE/SYSTEM/Explorer/Shell Folders]

"StartUp"="Flash Disk//StartUp"

这样,Windows CE开机后就会运行Flash Disk/StartUp目录下的所有.ExE文件.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Windows CE 是微软公司专为嵌入式系统开发的一款操作系统,它主要用于低功耗设备和嵌入式系统。在Windows CE平台上,可以使用C#或C++编写程序来读取txt文件。 如果是使用C#编写程序,可以使用StreamReader类来读取txt文件。首先,需要在代码中添加命名空间using System.IO,然后可以使用StreamReader的构造方法来创建StreamReader对象,并指定要读取的txt文件的路径: StreamReader reader = new StreamReader(@"C:\example.txt"); 接下来,可以使用ReadLine()方法来逐行读取txt文件的内容。通过读取的每一行,可以根据需要进行处理或保存到其他数据结构中,直到读取到文件的末尾为止。最后,需要使用Close()方法关闭StreamReader对象,释放资源。 示例代码如下: string line; while((line = reader.ReadLine()) != null) { //处理或保存每一行的内容 //... } reader.Close(); 如果是使用C++编写程序,可以使用fstream库来读取txt文件。首先,需要包含头文件#include <fstream>,然后可以创建fstream对象,并调用open()方法并指定要读取的txt文件的路径: std::ifstream file("C:\\example.txt"); 接下来,可以使用getline()方法来逐行读取txt文件的内容,并保存到一个字符串变量中。通过读取的每一行,可以根据需要进行处理或保存到其他数据结构中,直到读取到文件的末尾为止。最后,需要使用close()方法关闭文件流,释放资源。 示例代码如下: std::string line; while(std::getline(file, line)) { //处理或保存每一行的内容 //... } file.close() 以上是在Windows CE平台上使用C#和C++编程语言读取txt文件的基本步骤。具体的实现方式可以根据实际需求进行灵活调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值