Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Getting problem with RegisterShellFileTypes() in MFC Dialog based application. [modified]

Getting problem with RegisterShellFileTypes() in MFC Dialog based application. [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vasu_sri
    wrote on last edited by
    #1

    i created one dialog based application. In that Dlg App class i am calling RegisterShellFileTypes(), in CWInApp::initInstace. But application is crashing due to no poniter to document class. code is like this :

    CDesktopWallpaperDlg dlg;
    m\_pMainWnd = &dlg;
    
    EnableShellOpen();
    RegisterShellFileTypes();
    
    INT\_PTR nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
    	// TODO: Place code here to handle when the dialog is
    	//  dismissed with OK
    }
    else if (nResponse == IDCANCEL)
    {
    	// TODO: Place code here to handle when the dialog is
    	//  dismissed with Cancel
    }
    

    so, can anyone tell me what is the problem exactly? it working with SDI Application..

    Regards, Srinivas

    modified on Thursday, December 3, 2009 6:24 AM

    L K 2 Replies Last reply
    0
    • V vasu_sri

      i created one dialog based application. In that Dlg App class i am calling RegisterShellFileTypes(), in CWInApp::initInstace. But application is crashing due to no poniter to document class. code is like this :

      CDesktopWallpaperDlg dlg;
      m\_pMainWnd = &dlg;
      
      EnableShellOpen();
      RegisterShellFileTypes();
      
      INT\_PTR nResponse = dlg.DoModal();
      if (nResponse == IDOK)
      {
      	// TODO: Place code here to handle when the dialog is
      	//  dismissed with OK
      }
      else if (nResponse == IDCANCEL)
      {
      	// TODO: Place code here to handle when the dialog is
      	//  dismissed with Cancel
      }
      

      so, can anyone tell me what is the problem exactly? it working with SDI Application..

      Regards, Srinivas

      modified on Thursday, December 3, 2009 6:24 AM

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The problem is precisely what the error message says. RegisterShellFileTypes creates registry entries to associate a document type and file extension with an .exe. If you aren't using the MFC DocView framework, there is no document class and the function call fails. You can make the same registry entries manually; just because you aren't using the DocView framework doesn't mean you can't associate a file extension with an app, it just takes a bit more code.

      V 1 Reply Last reply
      0
      • V vasu_sri

        i created one dialog based application. In that Dlg App class i am calling RegisterShellFileTypes(), in CWInApp::initInstace. But application is crashing due to no poniter to document class. code is like this :

        CDesktopWallpaperDlg dlg;
        m\_pMainWnd = &dlg;
        
        EnableShellOpen();
        RegisterShellFileTypes();
        
        INT\_PTR nResponse = dlg.DoModal();
        if (nResponse == IDOK)
        {
        	// TODO: Place code here to handle when the dialog is
        	//  dismissed with OK
        }
        else if (nResponse == IDCANCEL)
        {
        	// TODO: Place code here to handle when the dialog is
        	//  dismissed with Cancel
        }
        

        so, can anyone tell me what is the problem exactly? it working with SDI Application..

        Regards, Srinivas

        modified on Thursday, December 3, 2009 6:24 AM

        K Offline
        K Offline
        KingsGambit
        wrote on last edited by
        #3

        It seems RegisterShellFileTypes() is to be used with SDI or MDI apps only.

        1 Reply Last reply
        0
        • L Lost User

          The problem is precisely what the error message says. RegisterShellFileTypes creates registry entries to associate a document type and file extension with an .exe. If you aren't using the MFC DocView framework, there is no document class and the function call fails. You can make the same registry entries manually; just because you aren't using the DocView framework doesn't mean you can't associate a file extension with an app, it just takes a bit more code.

          V Offline
          V Offline
          vasu_sri
          wrote on last edited by
          #4

          when i call this RegisterShellFileTypes() in App Class, internally in this function defination having pointer of document class. but dlg based application doesn't have doc class. so that, pointer is becoming NULL.

          void CWinApp::RegisterShellFileTypes(BOOL bCompat)
          {
          ASSERT(m_pDocManager != NULL);
          m_pDocManager->RegisterShellFileTypes(bCompat);
          }

          but,it is working fine with SDI Application. i have tried in one sample SDI application.

          Regards, Srinivas

          L 1 Reply Last reply
          0
          • V vasu_sri

            when i call this RegisterShellFileTypes() in App Class, internally in this function defination having pointer of document class. but dlg based application doesn't have doc class. so that, pointer is becoming NULL.

            void CWinApp::RegisterShellFileTypes(BOOL bCompat)
            {
            ASSERT(m_pDocManager != NULL);
            m_pDocManager->RegisterShellFileTypes(bCompat);
            }

            but,it is working fine with SDI Application. i have tried in one sample SDI application.

            Regards, Srinivas

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Yeah.... and what does SDI stand for? 'Single Document Interface'. It works in an SDI app because the SDI app has a document class, and fails in your dialog app because it doesn't have a document class.

            V 1 Reply Last reply
            0
            • L Lost User

              Yeah.... and what does SDI stand for? 'Single Document Interface'. It works in an SDI app because the SDI app has a document class, and fails in your dialog app because it doesn't have a document class.

              V Offline
              V Offline
              vasu_sri
              wrote on last edited by
              #6

              I know what is the SDI stand for.. what iam asking that, how to do in dialog based. i created one reg file. but what should be write in reg file instead of document class does.

              Regards, Srinivas

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups