Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How do I create a file association for my win32 application Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
24-Jul-02
Category
Win API
Language
Delphi 2.x
Views
98
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas 

How do I create a file association for my win32 application (Update for 
98/ME/NT5(2000)/ME) ?

Answer:

In Win32, create a new registry entry under the HKEY_CLASSES_ROOT root key that 
points to the file extension, the command line to invoke, and the icon to display. 
 
Update:

Windows will execute '\shell\open\command' from the KEY pointed in (Default) value. 

So you can :

Clear Default value of extention key with itself ex: .jpg -> .jpg. This make 
windows use '\shell\open\command' from the proper KEY. (As shown in example)

Create enother key like "MyProgExt" with '\shell\open\command' and point any 
extension you need to it. This way the extension key default value will be: 
MyProgExt.

Example:

1   uses Registry,
2   
3   procedure TForm1.FileFormatAssociations;
4   var
5     reg: TRegistry;
6     FileExt: string;
7   begin
8     reg := TRegistry.Create;
9     reg.RootKey := HKEY_CLASSES_ROOT;
10    reg.LazyWrite := false;
11  
12    FileExt := '.jpg';
13  
14    //Clear Key - This is important !!!
15    reg.OpenKey(FileExt, true);
16    reg.WriteString('', FileExt);
17    reg.CloseKey;
18  
19    //Invoke the program passing the file name as the first parameter
20    reg.OpenKey(FileExt + '\shell\open\command', true);
21    reg.WriteString('', Application.ExeName + ' "%1"');
22    reg.CloseKey;
23  
24    //Use the first icon in the executable to display
25    reg.OpenKey(FileExt + '\DefaultIcon', true);
26    reg.WriteString('', Application.ExeName + ',0');
27    reg.CloseKey;
28  
29    reg.free;
30  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC