Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Bind a C++ Qt application to a file extension on win32
Qt 6.11 is out! See what's new in the release blog

Bind a C++ Qt application to a file extension on win32

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 6.9k 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.
  • P Offline
    P Offline
    privet
    wrote on last edited by
    #1

    Hi,

    The .html file extension is bound to iexplore.exe on my win machine.
    If I doubleclik a html file in windows explorer, iexplore.exe will be launched.

    I have a Qt .exe application on win32 and I would like to bind a file extension to it:
    If I doubleclick a file with a specific extension, my app should be started
    (like the MFC functionality, see ::SetRegistryKey(...) in app::InitInstance();).

    Is there a Qt way to bind an extension to an application
    or I have to make it on the hard way and write several registry entries at the installation?

    Ciao

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      You can have a look at my "wiki article":http://developer.qt.nokia.com/wiki/Assigning_a_file_type_to_an_Application_on_Windows , that does exactly that :-)

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • P Offline
        P Offline
        privet
        wrote on last edited by
        #3

        cool! Thanks! That's what I was looking for! ;-)

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Nice article, Gerolf!

          1 Reply Last reply
          0
          • P Offline
            P Offline
            privet
            wrote on last edited by
            #5

            a little error: your code doesn't work correctly with paths containing spaces.
            The solution:
            registerCommand("Open", documentId, " "%1"", "[open("%1")]");
            (take care of the ")

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              Could you make that modification in the wiki article as well, please?

              1 Reply Last reply
              0
              • P Offline
                P Offline
                privet
                wrote on last edited by
                #7

                Wow, I has the right to edit the article.
                I did it.
                ...but...

                Maybe the following lines should be changed too in the same way:
                registerCommand("New", documentId, "-new %1", "[new("%1")]");
                registerCommand("Print", documentId, "-print %1", "[print("%1")]");

                I didn't try these lines, so I don't know, if here %1 should be changed too...?

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

                  Hoi privet,

                  I think they should be changed also.
                  I already did the changes. Thanks for reporting :-)

                  Gerolf

                  PS: I will also update the code on gitorious the next days

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    tanonl
                    wrote on last edited by
                    #9

                    I used this code but it didn't work in release mode.
                    In the function DocumentWindow::ddeExecute, the gotten command is empty when release mode.
                    @QString command = QString::fromWCharArray((LPCWSTR)::GlobalLock(hData)); @

                    Is it normal?

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      tanonl
                      wrote on last edited by
                      #10

                      [quote author="tanonl" date="1392757014"]I used this code but it didn't work in release mode.
                      In the function DocumentWindow::ddeExecute, the gotten command is empty when release mode.
                      @QString command = QString::fromWCharArray((LPCWSTR)::GlobalLock(hData)); @

                      Is it normal? [/quote]

                      I got it!!!
                      @WINBOOL b = ::UnpackDDElParam(WM_DDE_EXECUTE, message->lParam, &unused, (UINT_PTR*)&hData);
                      Q_ASSERT(b);@

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved