call windows' "open with" dialog

  • Thread starter Stefano Tonello
  • Start date
S

Stefano Tonello

Hi all,
I need to call windows' "open with" dialog from my C# windows form
application. After the user selects application, control must return to
me (I have to launch directly the process).
I found this solution:

http://www.codeproject.com/KB/shell/openwith.aspx

but it's not good for me since it will execute the process directly.

There is a way to call "open with" dialog and retieve selected application?

Thank you in advance

Bests,
Stefano Tonello
 
J

Jialiang Ge [MSFT]

Good morning Stefano. Welcome to Microsoft Newsgroup Support Service! My
name is Jialiang Ge [MSFT]. It's my pleasure to work with you on this post.

The solution at http://www.codeproject.com/KB/shell/openwith.aspx is the
same as the command:
Rundll32.exe shell32.dll, OpenAs_RunDLL C:\test.jpg

To retrieve the control of launching the selected application in our own
process after we bring up the "Open With" dialog, there is no direct way. (I
will explain the reason in detail). However, we may have some workarounds
depending on your specific context. Let's first look at the possible
solutions, then I will explain "WHY"s.

---- POSSIBLE SOLUTIONS ----

WORKAROUND 1: Building our own "Open With" dialog.

To be honest, rolling our own OpenAs dialog is something that is hard to
work perfectly. There will be many tests to do to eliminate the bugs. We can
get a list of apps registered to execute a certain file type by groveling
the registry http://windowsxp.mvps.org/OpenWith.htm or using the API:
SHAssocEnumHandlers
http://msdn.microsoft.com/en-us/library/bb762109(VS.85).aspx (The API is
available to Windows Vista and the above).

WORKAROUND 2: If your request can be adjusted to "how to get the selected
application in the 'Open With' dialog after the file is opened by the
default 'Open With' process", we can consider using the process handle:

http://forums.msdn.microsoft.com/en-US/vbide/thread/b1d31d9c-8b0b-4ffd-9372-74008a0632c6/
(see Martin's reply)

---- CAUSES -----

A. WHY can't I retrieve the control to launch the selected application in
our own process from the shell "Open With" dialog?

1. The OpenAs dialog runs in a separate process (rundll32.exe), so we have
no way of marshalling the process handle back from the OpenAs dialog process
into our process
2. Some types of apps do not support returning the process handle. Apps that
use DDE or drop target invocation does not return a process handle because
their model is typically to have one running process that multiple
ShellExecutes call into.

B. WHY isn't the first workaround very perfect?

Workaround 1 is not perfect because I'm not sure how you would actually
execute the file once the user selects the app. It would only work if the
executing app took a command line argument with the file name, which pretty
much rules out anything that uses DDE or IDropTarget.

Please let me know whether my suggestions are helpful to you. If you have
any other questions or concerns, DON'T hesitate to tell me.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notifications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

Duggi

Hi all,
        I need to call windows' "open with" dialog from my C# windows form
application. After the user selects application, control must return to
me (I have to launch directly the process).
I found this solution:

http://www.codeproject.com/KB/shell/openwith.aspx

but it's not good for me since it will execute the process directly.

There is a way to call "open with" dialog and retieve selected application?

Thank you in advance

Bests,
        Stefano Tonello

Hi

I think you can invoke "OpenWith" dialog only through interop services
provided by .Net. Try PInvoke for the same.

There is no direct way to as similar to OpenFileDialog /
ColorDialog .. etc.


-Cnu
 
J

Jialiang Ge [MSFT]

Hello Stefano,

I am writing to check the status of the issue on your side. Would you mind
letting me know the result of the suggestions? If you need further
assistance, feel free to let me know. I will be more than happy to be of
assistance.

Have a great day!

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
S

Stefano Tonello

Dear Jialiang,
I'm sorry for the late reply. I really appreciate your help.
I hope to work with you again

Bests,
Stefano Tonello

Jialiang Ge [MSFT] ha scritto:
 
J

Jialiang Ge [MSFT]

Hello Stefano,

You are surely welcome to work with me again. I look forward to more and
more successful cooperation with you in future. When you have any other
questions, please DON'T hesitate to post it in our newsgroups
(http://msdn.microsoft.com/en-us/subscriptions/aa974230.aspx) and we (MSFT)
will do our best to help you.

By the way, I notice that this is your first post to use our newsgroups. I
appreciate to hear from your comments/feedbacks of our support service,
website design, our product limitation, our process, and etc, so that we
can do better for you in future. (our feedback link: (e-mail address removed))

Have a great day!

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top