Operations related to the Delphi and Inno Setup files

Source: Internet
Author: User
Procedure tform1.button1click (Sender: tobject );
VaR
Reg: Tregistry;
Begin
Reg: = Tregistry. Create;
Reg. rootkey: = hkey_classes_root;

{Add our virtual. TST format in the registry, and specify the default value as testfile}
Reg. openkey ('. tst', true );
Reg. writestring ('', 'testfile ');
Reg. closekey;

{File opening Association}
Reg. openkey ('testfile \ shell \ open \ command', true );
Reg. writestring ('', paramstr (0) + '% 1 ');
Reg. closekey;

{File icon Association}
Reg. openkey ('testfile \ defaulticon ', true );
Reg. writestring ('', paramstr (0) + ', 0 ');
Reg. closekey;

Reg. Free;

{Refresh icon display}
Shchangenovel (shcn_assocchanged, shcnf_idlist, nil, nil );
End;

{Clear settings above}
Procedure tform1.button2click (Sender: tobject );
VaR
Reg: Tregistry;
Begin
Reg: = Tregistry. Create;
Reg. rootkey: = hkey_classes_root;
Reg. deletekey ('. tst ');
Reg. deletekey ('testfile ');
Reg. Free;
Shchangenovel (shcn_assocchanged, shcnf_idlist, nil, nil );
End;

You can also manually set file associations by opening a folder-tools-Folder Options-"file type" tab-and clicking "advanced ".

It is very convenient to use Inno. Instead of writing code, simply use the [registry] segment. For example:
[Registry]
Root: hkcr; subkey: "Real Media File"; valuetype: string; valuedata: "Real Media File"; flags: uninsdeletekey
Root: hkcr; subkey: "Real Media file \ defaulticon"; valuetype: string; valuedata: "{app} \ ABC. ICO"; flags: uninsdeletekey
Root: hkcr; subkey: "Real Media file \ shell \ open \ command"; valuetype: string; valuedata: "{app} \ myplayer.exe % 1"; flags: uninsdeletekey
Root: hkcr; subkey: "Real Media file \ shell \ open (& O) \ command" with my player; valuetype: string; valuedata: "{app} \ myplayer.exe % 1"; flags: uninsdeletekey
Root: hkcr; subkey: "*. rmvb"; valuetype: string; valuedata: "Real Media File"; flags: uninsdeletekey
Root: hkcr; subkey: "*. rm"; valuetype: string; valuedata: "Real Media File"; flags: uninsdeletekey
Root: hkcr; subkey: "*. Ra"; valuetype: string; valuedata: "Real Media File"; flags: uninsdeletekey

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.