Registration file Type settings file icon

Source: Internet
Author: User
Tags execution

{-------------------------------------------------------------------------------
@ Procedure name: Slpert-> Tfm_main. Setassociatedexec
@ Author: Gavin
@ Date: 2004.09.08
@ Feature Description:
@ parameters: Fileext, Filetype, FileDescription, MIM EType, execname:string
@ return value: Boolean
--------------------------------------------------------------------- ----------}
Function tfm_main. Setassociatedexec (Fileext, Filetype, FileDescription,
MimeType, execname:string): Boolean; {The modification succeeded, return true, or false}  
Var
Reg:tregistry;
Shfileinfo:tshfileinfo;
Iconindex:integer;
Begin
Result: = False; {}
//Shgetfileinfo (Pchar (Execname), 0, shfileinfo,sizeof (shfileinfo), Shgfi_largeicon or Shgfi_sysiconindex or Shgfi_typename or Shgfi_smallicon);
//iconindex:=shfileinfo.iicon;
//showmessage (IntToStr (IconIndex));
If (fileext = ') Or (execname = ') Then
Exit; {If the file type is empty or if no execution program is defined, Fileext must take ″.″, such as. BMP}
Reg: = tregistry.create;
 Try
Reg.rootkey: = HKEY_CLASSES_ROOT;
If not Reg.openkey (Fileext, True) Then
Exit; {When the Fileext key is not found correctly or when it is created, this is usually the case with an error in the registry.}
Reg.writestring (", FileType);   
If mimetype <> ' Then
Begin
reg.writestring (' Content Type ', mimetype);
End;
Reg.closekey;   
If not Reg.openkey (FileType, True) Then
Exit;
Reg.writestring (", filedescription);   
If not Reg.openkey (' Shell\open\command ', True) Then
Exit;
Reg.writestring (', Execname + ' "'%1 ');
{The execution program generally has parameters, such as the "Winzip32.exe″%1″" of WinZip, and the ″%1″ parameter refers to the file name of the zip file.)   Therefore execname should add the parameter}
Reg.closekey as appropriate;
  If not Reg.openkey (FileType + ' \defaulticon ', True) Then
Exit;
  Reg.writestring (', execname+ ', 1 ');   Extractfilepath (
Reg.closekey;
Result: = true;  
Finally
Reg.free;
End;
End;

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.