WEB开发网
开发学院软件开发Delphi 程序关联实现 阅读

程序关联实现

 2006-02-04 13:48:45 来源:WEB开发网   
核心提示:程序中readme是个.sos文件,点吉它实现如下: 基本实现如下:unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs,Registry,shlobj, Std
程序中readme是个.sos文件,点吉它实现如下:

基本实现如下:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
Registry,shlobj, StdCtrls, ExtCtrls;

type
TForm1 = class(TForm)
Memo1: TMemo;
Panel1: TPanel;
Button1: TButton;
PRocedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
procedure reg;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.reg;
var
reg: TRegistry;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_CLASSES_ROOT;
reg.OpenKey('.sos', true);
reg.WriteString('', 'myzip');
reg.CloseKey;
reg.OpenKey('myzip\shell\open\command', true);
//用于打开.sos文件的可执行程序
reg.WriteString('', '"' + application.ExeName + '" "%1"');
reg.CloseKey;
reg.OpenKey('myzip\DefaultIcon',true);
//取当前可执行程序的图标为.sos文件的图标
reg.WriteString('',''+application.ExeName+',0');
reg.Free;
//立即刷新
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);

end;
procedure TForm1.Button1Click(Sender: TObject);
begin
reg;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
sFile: string;
begin
if ParamCount > 0 then
begin
(* 取得参数内容 *)
sFile := ParamStr(1);
if LowerCase(ExtractFileExt(sFile))='.sos' then memo1.Lines.LoadFromFile(sfile);
end;
end;

end.

Tags:程序 关联 实现

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接