Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Application associated with file type

Posted on 2004-08-06
8
Medium Priority
?
190 Views
Last Modified: 2010-04-05
How do I find application name associated with a file extension,
for example; MDB -> Microsoft Access, TXT -> Notepad etc
0
Comment
Question by:graga
[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
  • 5
  • 2
8 Comments
 
LVL 4

Expert Comment

by:ErikPhilips
ID: 11739697
Solution 1:
- Open Explorer (to anywhere, my documents, c:\ whatever, where explorer opens to is irrelevant)
- from the menu Tools -> Options -> File Types.

Solution 2:
- Open Regedit
- File the Registry Path My Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
0
 

Author Comment

by:graga
ID: 11739907
Solution 1 is no good, It needs to be done from my Delphi application

Solution 2 gives me program executable, not application name. In my example, mdb gives msaccess.exe instead of Microsoft Access.
0
 
LVL 7

Expert Comment

by:LRHGuy
ID: 11740132
This should do it...

var
  e,s:string;
  R:tRegistry;
begin
  E:='psd';
  R:=TRegistry.Create;
  try
    R.RootKey := HKEY_CLASSES_ROOT;
    if R.OpenKey('.'+E,False) then begin
      S:=R.ReadString('');
      R.CloseKey;
      if (S<>'') and R.OpenKey(S,False) then begin
        S:=R.ReadString('');  //S has the "name"
        Message(E+' = '+S);
        R.CloseKey;
      end;
    end;
  finally
    R.Free;
  end;
end;
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 7

Expert Comment

by:LRHGuy
ID: 11740137
Oh, change  E:='psd' to whatever extension you're looking for..lowercase.

Enjoy!
0
 

Author Comment

by:graga
ID: 11740652
Thanks LRHGuy,

This is very close. However, the code returns file type instead of application name, for example,
'DOC' returns 'Microsoft Word Document' instead of 'Microsoft Word'
0
 
LVL 7

Expert Comment

by:LRHGuy
ID: 11741102
Here are the changes...it's a long trek...I leave the error checking to you...

E:='psd';

    R.RootKey:=HKEY_CURRENT_USER;
    if R.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.'+E+'\OpenWithList',false) then begin
      S:=R.ReadString('MRUList');
      S:=R.ReadString(S);
      R.CloseKey;
    end;
    R.RootKey:=HKEY_CLASSES_ROOT;
    if R.OpenKey('Applications\'+S+'\shell',false) then begin
      S:=R.ReadString('FriendlyCache');
      R.CloseKey;
      Message(E+' = '+S);
    end;

0
 
LVL 7

Expert Comment

by:LRHGuy
ID: 11741108
I suppose that doesn't find something in all cases. It found psd, ppp, and some others, but it doesn't seem to find doc or txt. ARGH!
0
 
LVL 7

Accepted Solution

by:
LRHGuy earned 500 total points
ID: 11741114
This seems to fix it...


E:='psd';

    R.RootKey:=HKEY_CURRENT_USER;
    if R.OpenKey('Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.'+E+'\OpenWithList',false) then begin
      S:=R.ReadString('MRUList');
      S:=R.ReadString(copy(S,1,1));  //looks at first item in list
      R.CloseKey;
    end;
    R.RootKey:=HKEY_CLASSES_ROOT;
    if R.OpenKey('Applications\'+S+'\shell',false) then begin
      S:=R.ReadString('FriendlyCache');
      R.CloseKey;
      Message(E+' = '+S);
    end;

 
 
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

715 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