Solved

Application associated with file type

Posted on 2004-08-06
8
182 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
  • 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
 
LVL 7

Expert Comment

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

Enjoy!
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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 125 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now