Results 1 to 16 of 16

Thread: [howto] making a windows shell extension with qt open-source edition

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jun 2010
    Posts
    9
    Thanks
    1
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [howto] making a windows shell extension with qt open-source edition

    Qt Code:
    1. The COM factory
    2. ---------------
    3.  
    4. In "shelloverlay.h", we will declare this class:
    5. class ShellOverlayBinder : public QObject, public QAxBindable {
    6. Q_OBJECT
    7.  
    8. public:
    9. ShellOverlayBinder(QObject *parent = 0);
    10.  
    11. QAxAggregated *createAggregate();
    12. };
    13.  
    14. Add a dllmain.cpp file to the project, which will contain:
    15.  
    16. #include <qt_windows.h>
    17. #include <ActiveQt>
    18. #include <QAxFactory>
    19. #include "shelloverlay.h"
    20. QT_USE_NAMESPACE
    21. QAXFACTORY_DEFAULT(ShellOverlayBinder,
    22. "{60c580d2-41f2-43ed-b5d1-b435d74d1999}", /* Class ID (CLSID) */
    23. "{21a9e71b-9ae4-4887-8ada-720442394493}", /* Interface ID (IID) */
    24. "{8c996c29-eafa-46ac-a6f9-901951e765b5}", /* event interface ID */
    25. "{a6b1968a-4bbc-4420-9a55-5ce3579f795a}", /* Type Library ID (TLB) */
    26. "{4f7d37e8-b9cb-4e66-a725-f043753b755c}" /* Application ID (AppID) */
    27. )
    28.  
    29. Every UUID in this file has to be generated. The ones were used on the author's machine and are fine for this tutorial, but if you want to make your own shell extension, you will have to generate new ones yourself.
    30.  
    31. - http://doc.trolltech.com/4.6/qaxfactory.html
    32.  
    33. Additional files, embedding the icon
    34. ------------------------------------
    35.  
    36. We will need a .def file, which will declare the exported symbols. The file from <qt>\src\activeqt\control\qaxserver.def will be enough, we can use it verbatim.
    37.  
    38. We will also need a .rc file, containing this:
    39.  
    40. 1 TYPELIB "qaxserver.rc"
    41. 1 ICON DISCARDABLE "qtoverlay.ico"
    42.  
    43. We will ultimately need an icon file. We will for example use Qt's favicon, modified so it only covers a quarter of the file.
    44.  
    45. % wget http://qt.nokia.com/favicon.ico
    46. % convert favicon.ico -alpha on -background none -gravity southeast -extent 32x32 qtoverlay.ico
    47.  
    48. We will put these 3 files at the root of our project dir. You can add also add them to the project in QtCreator.
    49.  
    50.  
    51. Build
    52. -----
    53.  
    54. QMake configuration
    55. +++++++++++++++++++
    56. The qmake .pro file will need some modifications.
    57. Add this:
    58.  
    59. CONFIG += dll qaxserver qt
    60.  
    61. qaxserver is used to include some default implementations (for the symbols from the .def file we previously included) ActiveQt provides and which suit our needs.
    62.  
    63. LIBS += -luser32 -lole32 -loleaut32 -lgdi32 -luuid
    64. DEF_FILE = qaxserver.def
    65. RC_FILE = qaxserver.rc
    66.  
    67. - http://doc.trolltech.com/4.6/qmake-manual.html
    68.  
    69. Include VisualStudioExpress tools path
    70. ++++++++++++++++++++++++++++++++++++++
    71. TODO this section needs work
    72. Open a "cmd" prompt, exec vcvars32.bat in it, and run qtcreator from there.
    73.  
    74. Build
    75. +++++
    76. The project should now build fine.
    77.  
    78.  
    79. Run
    80. ---
    81.  
    82. Installation
    83. ++++++++++++
    84. TODO this section needs work, the registry part should be in DllInstall perhaps in the future
    85.  
    86. A key with any name must be created in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers, and its default value should be the bracketed (with '{' and '}' around it) ClassID of our extension (the class id can be found in dllmain.cpp).
    87.  
    88. Registration and dependencies
    89. +++++++++++++++++++++++++++++
    90. TODO this section needs work
    91.  
    92. Unfortunately, the DLL has dependencies to other DLL files, that have to be copied in the same directory as our DLL, these are:
    93. - mingwm10.dll (found in <qt>\bin)
    94. - libgcc_s_dw2-1.dll (found in <qt>\bin)
    95. - QtCore4.dll (or QtCored4.dll if the extension is built in "debug")
    96. - QtGui4.dll (or QtGuid4.dll if debug) (TODO this should not be needed)
    97.  
    98. The extension can now be registered, by typing "regsvr32 shellext_overlay.dll".
    99.  
    100. If regsvr32 says "the specified module could not be found", it may have some other dependencies. The "Dependency Walker" tool can be used to find them.
    101.  
    102. - http://www.dependencywalker.com/
    103.  
    104. Test
    105. ++++
    106.  
    107. Now, we can start notepad (or any app with a file selection dialog), select "open..." and watch our shell extension at work!
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to Tilda for this useful post:


Similar Threads

  1. Replies: 1
    Last Post: 8th February 2009, 15:08
  2. OLE with Qt Open Source Edition??
    By Arpan in forum Qt Programming
    Replies: 3
    Last Post: 6th August 2008, 14:00
  3. Open Source on Windows
    By yogeshgokul in forum Installation and Deployment
    Replies: 3
    Last Post: 29th January 2008, 09:54
  4. Qt/Windows Open Source Edition to support VS Express
    By pdolbey in forum Installation and Deployment
    Replies: 3
    Last Post: 23rd September 2007, 14:32
  5. Qtopia 4.2 Open Source edition released!
    By lpotter in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 21st December 2006, 20:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.