那位大虾知道VC中怎么实现基于Dialog的程序与文件关联。
平时我们打开*.doc,文档的时候,双击这个文件就可以用制定的office软件打开。
我做的一个基于Dialog的小程序(如Player.exe),在用的过程中保存了一个文档(如Test.LST),我想再双击这个保存的文档(Test.LST)的时候,能用那个小软件(Player.exe)还原打开。
这个怎么实现?
谢谢大家!

解决方案 »

  1.   

    在注册表里添加一些键值,你可以搜索.txt文件的关联键值,模仿它创建自己的值
      

  2.   

    我在程序中写了一个函数:
    void CFangtekApp::RegisterFile(CString strFileName)
    { CString strKey, strKeyValue ;
    HKEY hKey ; strKey = CString(".lst") ;
    strKeyValue = CString("lstfile") ;

    RegCreateKey(HKEY_CLASSES_ROOT,strKey,&hKey) ;
    RegSetValue(HKEY_CLASSES_ROOT,strKey,REG_SZ,strKeyValue,strKeyValue.GetLength()) ;
    strKey = CString("lstfile") ;
    strKeyValue = CString("lst音频工程文件") ; RegCreateKey(HKEY_CLASSES_ROOT,strKey,&hKey) ;
    RegSetValue(HKEY_CLASSES_ROOT,strKey,REG_SZ,strKeyValue,strKeyValue.GetLength()) ;
    HKEY hSubKey ;
    strKeyValue = strFileName ;
    RegCreateKey(hKey,"Shell\\Open\\Command",&hSubKey) ;
    RegSetValue(hKey,"Shell\\Open\\Command",REG_SZ,strKeyValue,strKeyValue.GetLength()) ;
    }
    在应用程序的初始化中
             char strFileName[256] ;
    memset(strFileName,0,256) ;
    GetModuleFileName(NULL,strFileName,256) ;
    RegisterFile(strFileName) ;

    现在双击我保存的文件名是可以调用自己的程序来运行。但是不能把数据显示在软件的界面。
    请问大家怎么是为什么,怎么解决?
      

  3.   

    CString m_str;
    m_str=GetCommandLine();