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



  • 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



  • 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 :-)



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



  • Nice article, Gerolf!



  • 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 ")



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



  • 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...?



  • 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



  • 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 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);@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.