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

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

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
On Fri, 22 Jul 2005 10:19:17 -0700, "Vagabond Software" <vagabondsw-X-@-X-gmail.com> wrote:

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)
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.