Solved

Associated program

Posted on 2002-05-28
5
184 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 147 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sorting multiple rows and columns, and count duplicates in Excel 2013 4 101
Hide vba in gp 7 125
Recommendation vb6 to vb.net or others 14 238
Automatic Email Reminder 4 94
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

737 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