By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,589 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,589 IT Pros & Developers. It's quick & easy.

call windows' "open with" dialog

P: n/a
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
Aug 3 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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/libr...09(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-...-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 (ji****@online.microsoft.com, 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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...#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/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

"Stefano Tonello" <cu********@newsgroup.nospamwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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

Aug 4 '08 #2

P: n/a
On Aug 3, 10:55*pm, Stefano Tonello <cubevis...@newsgroup.nospam>
wrote:
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
Aug 4 '08 #3

P: n/a
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 (ji****@online.microsoft.com, 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:
ms****@microsoft.com.

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

Aug 6 '08 #4

P: n/a
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:
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 (ji****@online.microsoft.com, 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:
ms****@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
Aug 7 '08 #5

P: n/a
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/subs.../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: ms****@microsoft.com)

Have a great day!

Regards,
Jialiang Ge (ji****@online.microsoft.com, 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:
ms****@microsoft.com.

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

Aug 8 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.