Solved

File Associations

Posted on 1998-12-04
3
157 Views
Last Modified: 2010-04-04
How do I check the Win32-Registry for the Association of specified File Types, to see if they are assigned to my Program ?
0
Comment
Question by:omsec
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
sassas081597 earned 20 total points
ID: 1349273
Here is an example of looking for assosiation.
  Uses Registry;

  With TRegistry.Create Do
  Begin
    RootKey := HKEY_Classes_Root;
    OpenKeyReadOnly('.XXX');
    ExtName := ReadString('');
    CloseKey;

    ExtName := ExtName + '\shell\open\command';
    OpenKeyReadOnly(ExtName);
    AppPath := ReadString('');
    CloseKey;

    ShowMessage(AppPath);
  End;
The AppPath is what you are looking for.
0
 
LVL 2

Author Comment

by:omsec
ID: 1349274
could you please also post a short code, to write a new association to the registry ?

XXX   = My Program File (Description of the Type)
0
 
LVL 1

Expert Comment

by:sassas081597
ID: 1349275
Here you are
const AppPath : 'C:\MyPath\...'
with TRegistry.Create do
   try
     RootKey := HKEY_Classes_Root;
     OpenKeyReadOnly('.XXX');
     ExtName := ReadString('');
     CloseKey;

     ExtName := ExtName + '\shell\open\command';
     OpenKey(ExtName,True);
     WriteString('Default', AppPath);
     CloseKey;
   finally
      Free;
   end;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 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

17 Experts available now in Live!

Get 1:1 Help Now