[Qt-interest] Search and launch Application

Malyushytsky, Alex alex at wai.com
Thu May 21 04:05:17 CEST 2009


Under the Windows you normally get information about application from the registry.
If  that is impossible application is doing global hard drive search ( usually during installation ) and/or allows user specify the application he wants to be launched in the specific case.

This is true in general case, but associations with  media files are a bit different.

1. First of all keep in mind that normally under the Windows file is associated with application via the extension. And the question is not in finding the Windows media player, but to launch an application which is designated by user to show such files. Sometimes the "launching" command has some parameters, in addition to the executable name. So you need to find which application is setup to start for such file extension by default.

How it is done?

Such associations are kept in the registry and each file extension can give you information about what to launch and how.

For example in a HKEY_CLASSES_ROOT
You can find which application is associated with avi extension, checking
HKEY_CLASSES_ROOT\.avi\OpenWithList should have wmplayer.exe key set, it is default for such files

For .cda on my system it will also list ITunes.exe (HKEY_CLASSES_ROOT\.cda\OpenWithList)


Now when you know which file  (assume it is wmplayer.exe), you need to find where it is located.


HKEY_CLASSES_ROOT\Applications\wmplayer.exe\shell will give you default action.

For example assuming it is "open" you can find command to be launched at

HKEY_CLASSES_ROOT\Applications\wmplayer.exe\shell\open\command\

Value name (Default) should give you a command at value, something like this:

C:\Program Files (x86)\Windows Media Player\wmplayer.exe /Open "%L"


Here is what you were looking for.

Good news, if it were iTunes you would get similar result following the same logic.
On my system you would end up with:
"C:\Program Files (x86)\iTunes\iTunes.exe" /play "%L"

Bad news, everything here is system dependant, at least Windows dependant.
And even if you can use QT classes to get such information, it is still not applicable to other systems.

I have not checked any documentation and have not done it for a few years, so you might want to check msdn how it should be done, before taking my words, but I am pretty sure registry is the standard way to resolve the problem you are looking into.

Best regards,
    Alex




From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Rahulkumar Tibdewal
Sent: Wednesday, May 20, 2009 7:12 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] Search and launch Application

Hi All,

I want to launch the particular application on my machine using Qt code.
For example if I am working on MAC OS X and wish to launch iTunes.
Or if I am working on Windows and I wish to launch Windows media player.

However there can be cases that Applications are installed at different locations.
For example in windows applications can be installed at different locations.
In Mac OS X we can install applications in Applications Folder. On Mac applications are usually Bundles so we can change their position and can launch them from anywhere.

So basically If we are provided with the name of application then
1. Search the application
2. Launch the application.


Can anyone give me clues on this topics.

Thanks
Rahul
DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.


---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."

"Please consider our environment before printing this email."




More information about the Qt-interest-old mailing list