zoukankan      html  css  js  c++  java
  • wince Automatically Start Application with Command Line Parameters

    The short answer is that you cannot pass command line parameters to the application when using HKEY_LOCAL_MACHINE\Init to launch your application (although a command line parameter is passed to it for use with SignalStarted()). But maybe you really need to use this key to start your application because you don’t want a user to remove your application from the Startup folder, so let’s look at how this could be done.
    Since we can’t pass parameters to the application directly using the Init key, what we need to do is write a second application to do it. In this case, let’s assume that the application that you want to start is third-party application that does not call SignalStarted() so we will do that for it. What we will do is start the application using CreateProcess() and then call SignalStarted().
    #include <Windows.h>
    int WINAPI WinMain( HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPTSTR lpCmdLine,
    int nCmdShow)
    {
    PROCESS_INFORMATION pi;
    if (CreateProcess( TEXT("iesample.exe"), TEXT("\\Storage Card\\Index.html"), NULL, NULL, FALSE, 0,NULL, NULL, NULL, &pi))
    {
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
    }
    SignalStarted( _wtol(lpCmdLine) );
    }
    This example will start iesample.exe with \Storage Card\Index.html loaded and displayed.
    The downside of this is that you probably need to be a software developer to turn this into an exe that you can use, if you are not then you probably won’t be using the Init key but instead will use the Startup folder.
     
    Startup Folder with Command Line
    You can’t put your application in the Startup folder and pass it command line parameters, but you can put a shortcut file to your application in the Startup folder and include the command line arguments in the shortcut file.
    A shortcut file is a file with a LNK extension that contains:
    <Number>#<Command> <Parameters>
    Where:
    Number is the number of characters after the pound sign (#)
    Command is the application that you want to run
    Parameters are the command line parameters to pass to the application
    So to start iesample.exe and load \Storage Card\Index.html, I created a file named StartExplorer.exe.lnk. I include the exe for two reasons; it makes it look like an exe to the user and the LNK extension will not be displayed. If you leave out the exe, it will still work but it will be displayed in the file explorer as StartExplorer.lnk which I think looks odd.
    The contents of the file are:
    37#iesample.exe \Storage Card\Index.html
    Now put this shortcut in the \Windows\Startup folder. The catch is that your Startup folder may not persist, but if you are developing the OS you can put this shortcut in the OS and use your DAT file to copy it to the Startup folder (see Platform Builder: Using Dat Files to Initialize the File System for more)
    Another solution would be to use a batch file, but I don’t think that has any advantage over a shortcut and it has a few disadvantages. The disadvantages are that your OS must include a command window and the command window will open before your application. But here is a simple batch file that opens iesample.exe and loads \Storage Card\Index.html:
    @echo off
    iesample \Storage Card\Index.html
     
  • 相关阅读:
    ESP8266型号对比
    Arduino安装ESP8266开发库
    ESP8266驱动I2C OLED显示屏
    爬虫与反爬技术汇总
    爬虫之爬取某道技术分析
    爬虫之12306模拟登陆和购票
    web开发之用户单点登陆和多用户登陆实现
    爬虫中如何获取图片验证码
    web开发中图片保存问题
    python的缓存机制
  • 原文地址:https://www.cnblogs.com/zym0805/p/2213734.html
Copyright © 2011-2022 走看看