Results 1 to 7 of 7

Thread: how can i associate my program with a specific file?

  1. #1
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Question how can i associate my program with a specific file?

    hi everybody;
    lately i developed a simple program that handles text files on windows .
    i want to know how to make my program the default one for txt file type?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: how can i associate my program with a specific file?

    Qt doesn't offer any direct way to do this. You will have to use WinAPI directly or modify registry with help of QSettings.
    J-P Nurmi

  3. #3
    Join Date
    Feb 2008
    Posts
    154
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how can i associate my program with a specific file?

    yes, i know.
    but how can i use QSettings to do that.
    note that i know how to use QSettings but i do not know which key sholud i change.
    and thank you for your co-operation.

  4. #4
    Join Date
    Nov 2007
    Posts
    89
    Thanked 21 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how can i associate my program with a specific file?

    See http://msdn2.microsoft.com/en-us/library/bb776847.aspx

    Briefly, you should add a .ext key to HKEY_CLASSES_ROOT, then set its default value to extfile. Then add a extfile key to HKEY_CLASSES_ROOT, with subkeys DefaultIcon (default value = icon) and shell/open/command (default value = "/path/to/app %1").
    See .txt and txtfile keys for an example.

  5. #5
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: how can i associate my program with a specific file?

    Does anybody know how to open files in your program when it runs and user double clicks on the file which is associated with your program ?
    C++ & AMD forever

  6. #6
    Join Date
    Nov 2007
    Posts
    89
    Thanked 21 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how can i associate my program with a specific file?

    Quote Originally Posted by THRESHE View Post
    Does anybody know how to open files in your program when it runs and user double clicks on the file which is associated with your program ?
    Do you mean when user double clicks on a file and its associated application is already running?
    You have to use some interprocess communication system. Basically, when your app starts, it must check if another instance is running, and if yes it must send it a message (i.e. open a new file).
    You can use sockets, or lock files, or platform specific ways (i.e. mutexes and mailslots on windows).

  7. #7
    Join Date
    Mar 2007
    Location
    Ukraine, Odessa
    Posts
    140
    Thanks
    15
    Thanked 11 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: how can i associate my program with a specific file?

    Quote Originally Posted by bender86 View Post
    Do you mean when user double clicks on a file and its associated application is already running?
    Yes I do mean that
    Quote Originally Posted by bender86 View Post
    You have to use some interprocess communication system. Basically, when your app starts, it must check if another instance is running, and if yes it must send it a message (i.e. open a new file).
    You can use sockets, or lock files, or platform specific ways (i.e. mutexes and mailslots on windows).
    Thanks for reply but I've just found the way how to do it here http://www.qtcentre.org/forum/f-qt-p...nce-11824.html
    Honestly I thought that I should do it the way it is described in that topic. But I thought that Qt already has this feature...
    C++ & AMD forever

Similar Threads

  1. Replies: 5
    Last Post: 29th October 2007, 23:49
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 16:21
  3. QT MySQL
    By sabeeshcs in forum Newbie
    Replies: 6
    Last Post: 12th January 2007, 05:19
  4. Writing to file at specific
    By safknw in forum Qt Programming
    Replies: 3
    Last Post: 1st December 2006, 12:12
  5. Replies: 2
    Last Post: 13th September 2006, 10:11

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.