er***********@yahoo.com (Gos) scripsit:
I have a program that needs to open a list of attachments
displayed on a ListView. I have used Process.Start method to open the
files using their associated program. This works correctly if the file
extention is associated with a process(program/application) already,
but throws an exception when there is no associated process. I would
like to display an "Open With.." dialog box where the user can choose
a program to open the file.
You can catch the exception and call the function below:
PInvoke, seems to be undocumented:
\\\
Private Declare Function OpenWithDialog Lib "shell32.dll" _
Alias "OpenAs_RunDLL" ( _
ByVal hWndOwner As IntPtr, _
ByVal dwUnknown1 As Int32, _
ByVal strFileName As String, _
ByVal dwUnknown2 As Int32 _
) As Int32
Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles Button1.Click
OpenWithDialog(Me.Handle, 0, "C:\AUTOEXEC.BAT", 0)
End Sub
///
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>