ERROR_NO_ASSOCIATION returned by ShellExecuteEx() instead of popup "Choose associated app" dialog.

Posted on 2006-05-15
Medium Priority
Last Modified: 2008-01-09
Hi Experts,

I'd used ShellExecuteEx() to open an user selected file, the problem is that when the file type of selected file has no associated application, I'd like my program behave exactly like how Windows does,
pops up the dialog to:
  1. Use the Web service to find the appropriated program.
  2. Select the program from a list.

Instead of poping up the dialog described above, An error dialog popup "This file does not have a program associated with it for performing this action. Create an association in the Folder Options control panel".

GetLastError() returns ERROR_NO_ASSOCIATION.
SHELLEXECUTEINFO::lpVerb = "open";

Thanks in advance.
Question by:teltel
1 Comment
LVL 49

Accepted Solution

DanRollins earned 2000 total points
ID: 16693589
Interesting question.  It took some searching, but I found that you can bring up the "Open With" dialog by executing this command:

   rundll32.exe Shell32.dll,OpenAs_RunDLL c:\temp\junk.txt

   (see http://support.microsoft.com/kb/q218805/ )

So what you should do is call the FindExecutable() API...

If it returns an indication no file association, then use ShellExecute()...
...To execute that command line (the program to execute is
and the parameters are
     Shell32.dll,OpenAs_RunDLL full-path-and-filename-and-extension

One thing to note: The word
must be spelled right (and character case is important!!!!).

If you need help with making the ShellExecute function work, then let me know.

-- Dan

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month15 days, 18 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question