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
     
  • 相关阅读:
    git基础命令学习总结
    php 阿里云短信服务及阿里大鱼实现短信验证码的发送
    用Laravel Sms实现 laravel短信验证码的发送
    php定时执行操作及ob_flush()与flush()的使用
    composer安装laravel指定版本
    laravel5.4生成验证码
    larave5.4自定义公共函数的创建
    laravel5.4生成验证码
    Swagger解决你手写API接口文档的痛
    不是所有OutOfMemoryError异常都跟内存有关
  • 原文地址:https://www.cnblogs.com/zym0805/p/2213734.html
Copyright © 2011-2022 走看看