Delphi关联文件扩展名
unit unitMain;
interface
uses
Registry, shlobj,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TExtForm = class(TForm)
ledExtension: TLabeledEdit;
ledAssocApp: TLabeledEdit;
GetAssocApp: TButton;
AssocThisButton: TButton;
procedure FormCreate(Sender: TObject);
procedure AssocThisButtonClick(Sender: TObject);
procedure GetAssocAppClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ExtForm: TExtForm;
implementation
{$R *.dfm}
function GetExeByExtension(sExt : string) : string;
var
sExtDesc:string;
begin
with TRegistry.Create do
begin
try
RootKey:=HKEY_CLASSES_ROOT;
if OpenKeyReadOnly(sExt) then
begin
sExtDesc:=ReadString('') ;
CloseKey;
end;
if sExtDesc <>'' then
begin
if OpenKeyReadOnly(sExtDesc + '\Shell\Open\Command') then
begin
Result:= ReadString('') ;
end
end;
finally
Free;
end;
end;
if Result <> '' then
begin
if Result[1] = '"' then
begin
Result:=Copy(Result,2,-1 + Pos('"',Copy(Result,2,MaxINt))) ;
end
end;
end;
procedure RegisterFileType(ExtName:String; AppName:String) ;
var
reg:TRegistry;
begin
reg := TRegistry.Create;
try
reg.RootKey:=HKEY_CLASSES_ROOT;
reg.OpenKey('.' + ExtName, True) ;
reg.WriteString('', ExtName + 'file') ;
reg.CloseKey;
reg.CreateKey(ExtName + 'file') ;
reg.OpenKey(ExtName + 'file\DefaultIcon', True) ;
reg.WriteString('', AppName + ',0') ;
reg.CloseKey;
reg.OpenKey(ExtName + 'file\shell\open\command', True) ;
reg.WriteString('',AppName+' "%1"') ;
reg.CloseKey;
finally
reg.Free;
end;
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil) ;
end;
procedure TExtForm.FormCreate(Se
相关文档:
最近要做一个图书管理系统,并且是用Delphi软件开发,很多都不懂,本来是可以从网上下载,学习一下的,可是不知道怎么破解登陆密码,运行时没办法登陆进去,5555~~好好学习,有高手指点就好了…… ......
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB,comobj, OleServer,
ExcelXP;
type
TForm1 = class(TForm)
ADOConn: TADOConnection;
& ......
Ctrl+PageUp 将光标移至本屏的第一行,屏幕不滚动。
Ctrl+PageDown 将光标移至本屏的最后一行,屏幕不滚动。
Ctrl+↓ 向下滚动屏幕,光标跟随滚动不出本屏。
Ctrl+↑ &nb ......
function GetFileSizeString(const pFileName: String):String;
var
iFileSize: Int64;
begin
Result := '0';
iFileSize := FileSizeByName(pFileName);
Result := IntToStr(iFileSize);
end;
function WinExecAndWait(strFileName: string; uCmdShow: UINT): DWORD;
var
cAppName: array ......
unit unitMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2 ......