?
Solved

Associated program

Posted on 2002-05-28
5
Medium Priority
?
190 Views
Last Modified: 2010-05-02
I need a quick and easy way of finding the program associated with a file extension.

First to see will take.
0
Comment
Question by:Belazir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7039075
could you elaborate on this!
0
 

Author Comment

by:Belazir
ID: 7039090
As in, a bit of code to find out what is registered as being the program associated with any file extension.  For example, I am iterating through a list of files, some of which might be .jpg, some of which might be .gif, some of which might be .doc, and some of which might be .ras.  How do I find out what is the program registered on the user's computer as being associated with each extension?
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 588 total points
ID: 7039105
Ok, this example demonstrates how to find the executable associated with a specific file. The file must exist for this to work:

Const MAX_FILENAME_LEN = 260
Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As String) As Long
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net
   Dim i As Integer, s2 As String
   Const sFile = "C:\Windows\Readme.txt"

   'Check if the file exists
   If Dir(sFile) = "" Or sFile = "" Then
        MsgBox "File not found!", vbCritical
        Exit Sub
   End If
   'Create a buffer
   s2 = String(MAX_FILENAME_LEN, 32)
   'Retrieve the name and handle of the executable, associated with this file
   i = FindExecutable(sFile, vbNullString, s2)
   If i > 32 Then
      MsgBox Left$(s2, InStr(s2, Chr$(0)) - 1)
   Else
      MsgBox "No association found !"
   End If
End Sub

0
 

Author Comment

by:Belazir
ID: 7039123
that will do nicely

a very profitable five minutes for you, there...
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 7039153
Two out of two cannot be bad indeed. Happy to have helped.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question