在你的工程的CWinApp派生类的InitInstance()方法中有如下代码(自动生成的):
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
cmdInfo中有相关信息,其中cmdInfo.m_strFileName为文件名。

解决方案 »

  1.   

    用VC的AppWizard创建一个MFC EXE文件,带Doc/View模式,在Step 4中选Advanced按扭,在File extension中输入你的扩展名,然后编译运行,以后就可以在资源管理器中直接点击此扩展名的文件来运行你的程序。
      

  2.   

    我是指程序能够识别是哪个文件启动的它,例双击MP3文件WINAMP就直接播放它!!!
      

  3.   

    这一步是由系统完成的,就是文件关联了。安装了Winamp后,在系统中MP3文件(还有其它一些文件类型)已与Winamp进行了关联。用户双击MP3文件时,系统会自动调用Winamp,并将用户双击文件的文件名作为参数传给Winamp。不知这次的回答是不是你想要的?
      

  4.   

    应用程序安装时,会在系统注册表中添加一项,注时自己所支持的文档的后缀名。你可运行regedit.exe,打开系统注册表,可看到WINDOWS中所有注册的文档后缀。用户双击任何文件,WINDOWS自动搜索注册表,如果该后缀存在,则调用相应的应用程序,并传递文件名;如果不存在,则调出对话框,请求用户指定启动该文件的应用程序。
      

  5.   

    If you want to get the command line of an application, you can parse m_lpCmdLine member variable in app class by yourself, the following is parse commandif(m_lpCmdLine[0] != _T('\0'))
    {
        CString m_strFileName;
        CString m_strTemp = CString(m_lpCmdLine);
        if(m_lpCmdLine[0] == '\"')
            m_strFileName = m_strTemp.Mid(1, m_strTemp.GetLength() - 2);
        else
            m_strFileName = m_strTemp;
    }
    In this sample the variable m_strFileName is the file name you clicked in explore.Best wishes
    ------
      

  6.   

    用户双击MP3文件时,系统会自动调用Winamp,并将用户双击文件的文件名作为参数传给Winamp,在程序里怎样得到该文件名?
      

  7.   

    是由CommandLine读出的名字,Sniper说得很清楚了