Determining the application currently associated w/ file type...

V

Vagabond Software

I'm writing an application where then end-user will want to view and print
(not edit) TIFF and JPEG images. For now, I simply use the
System.Diagnostics.Process.Start method to open the desired image with the
application currently associated with that file type.

However, sometimes the wrong application is associated with a file type.
For example, Microsoft Office Picture Manager will only display the first
page of a multi-page TIFF image with no way to view the additional pages
(that I know of). Also, I suspect it may be possible that some older
machines running Windows ME or Windows 98 may not have an application
associated with TIFF images.

So, I'd like to check on the current application associated with TIFF
images. What is the best way to go about doing that?

Any advice or suggestions are greatly appreciated.

Thanks,

Carl
 
P

Paul Clement

¤ I'm writing an application where then end-user will want to view and print
¤ (not edit) TIFF and JPEG images. For now, I simply use the
¤ System.Diagnostics.Process.Start method to open the desired image with the
¤ application currently associated with that file type.
¤
¤ However, sometimes the wrong application is associated with a file type.
¤ For example, Microsoft Office Picture Manager will only display the first
¤ page of a multi-page TIFF image with no way to view the additional pages
¤ (that I know of). Also, I suspect it may be possible that some older
¤ machines running Windows ME or Windows 98 may not have an application
¤ associated with TIFF images.
¤
¤ So, I'd like to check on the current application associated with TIFF
¤ images. What is the best way to go about doing that?
¤
¤ Any advice or suggestions are greatly appreciated.

You can use the FindExecutable API function call:

Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As
String, _
ByVal lpDirectory As
String, _
ByVal lpResult As
System.Text.StringBuilder) As Int32

Function FindAssociatedApp(ByVal FullFilePath As String) As String

Dim FileDir As String

Dim FileExecutablePath As New System.Text.StringBuilder(255)

If FindExecutable(FullFilePath, FileDir, FileExecutablePath) > 32 Then
Return (FileExecutablePath.ToString)
End If

End Function


FileExecutablePath = FindAssociatedApp("e:\My Documents\book1.xls")



Paul
~~~~
Microsoft MVP (Visual Basic)
 

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