请问如何实现双击文件图标,用自己的程序打开?双击文件图标后,文件路径是否保存在注册表某处?如何编程实现?

解决方案 »

  1.   

    在app类中调用下面的函数RegisterShellFileTypes 
    CWinApp::RegisterShellFileTypes 
    void RegisterShellFileTypes( BOOL bCompat = FALSE );ParametersbCompatTRUE adds registration entries for shell commands Print and Print To, allowing a user to print files directly from the shell, or by dragging the file to a printer object. It also adds a DefaultIcon key. By default, this parameter is FALSE for backward compatibility.ResCall this member function to register all of your application’s document types with the Windows File Manager. This allows the user to open a data file created by your application by double-clicking it from within File Manager. Call RegisterShellFileTypes after you call AddDocTemplate for each of the document templates in your application. Also call the EnableShellOpen member function when you call RegisterShellFileTypes.RegisterShellFileTypes iterates through the list of CDocTemplate objects that the application maintains and, for each document template, adds entries to the registration database that Windows maintains for file associations. File Manager uses these entries to open a data file when the user double-clicks it. This eliminates the need to ship a .REG file with your application.If the registration database already associates a given filename extension with another file type, no new association is created. See the CDocTemplate class for the format of strings necessary to register this information.
      

  2.   

    如果是基于文档的
    可以在appwizard的第四步(如果没记错的话)advanced中修改支持文件的扩展名
    然后再如上面仁兄说的加上
    在app类中调用下面的函数RegisterShellFileTypes 
    CWinApp::RegisterShellFileTypes 
    void RegisterShellFileTypes( BOOL bCompat = FALSE );
      

  3.   

    技术内幕里面都讲的很清楚  你可以去看看这本书
    我把里面的两幅图截了出来你可以先看看
    http://kingeyes.51.net/b.jpg
    http://kingeyes.51.net/a.jpg