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

Posted on 2006-05-15
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

    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 )

    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

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    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++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now