如题。
鄙人正在独自写一个文件加密软件,想完成以下动作:右击多个文件,调用一个MFC exe程序加密选中的文件--这些文件的路径、名称通过类似命令行参数的形式获得。
最好给个示例,谢谢!

解决方案 »

  1.   

    掉命令行格式为
     path\jiami.exe 文件完全路径1;文件完全路径2;......
      

  2.   

    我知道 关键是 MFC exe 程序怎么使它接受我们的参数
    控制台应用程序我知道怎么做: main函数可带命令行参数
      

  3.   

    我所知道的做法:
    1.覆写CXXXApp的基类的成员函数void  CWinApp::ParseCommandLine(CCommandLineInfo& rCmdInfo)以执行你想要的操作.
    例如:
    [code]
    void  CMyProgramApp::ParseCommandLine(CCommandLineInfo& rCmdInfo)
    {
    LPCTSTR pszParam = __targv[1];
            //以消息框形式输出它的第一个命令行参数,第零个参数为应用程序名称本身
    MessageBox(NULL,pszParam,"MyProgram.exe",MB_OK);
      return;
    }
    [/code]
    2.在InitInstance函数中可以这样写以示对命令行参数的处理:
    [code]
    BOOL CListApp::InitInstance()
    {
    AfxEnableControlContainer(); // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.#ifdef _AFXDLL
        Enable3dControls(); // Call this when using MFC in a shared DLL
    #else
        Enable3dControlsStatic(); // Call this when linking to MFC statically
    #endif
        CCommandLineInfo cmdInfo;
        ParseCommandLine(cmdInfo);
        ... ...
    }
    [/code]
      

  4.   

    我所知道的做法: 
    1.覆写CXXXApp的基类的成员函数void  CWinApp::ParseCommandLine(CCommandLineInfo& rCmdInfo)以执行你想要的操作. 
    例如: 
    void  CXXApp::ParseCommandLine(CCommandLineInfo& rCmdInfo)
    {
    LPCTSTR pszParam = __targv[1];
    if(NULL != pszParam)
    {
    MessageBox(NULL,pszParam,"XX",MB_OK);
    }
      return;
    }2.在InitInstance函数中可以这样写以示对命令行参数的处理: 
    BOOL CXXApp::InitInstance()
    {
    AfxEnableControlContainer(); // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.#ifdef _AFXDLL
    Enable3dControls(); // Call this when using MFC in a shared DLL
    #else
    Enable3dControlsStatic(); // Call this when linking to MFC statically
    #endif
        
        //以下为添加的代码
        CCommandLineInfo cmdInfo;
        ParseCommandLine(cmdInfo);
        ... ...
    }