Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Application associated with file type

Posted on 2004-08-06
8
Medium Priority
?
192 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Integration Management Part 2
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

772 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