谈Delphi下
谈Delphi下Internet的编程技巧(一)
作者:lyboy99
E-mail:lyboy99@sina.com
Delphi带了很多的Internet应用编程控件,这使得我们开发Internet的应用程序可以轻松些,下面我将逐步介绍一些关于Internet下应用程序编程技巧,这些技巧都是一些细微的方面,但是它却可以给你的应用程序添加重要的功能,将使你开发Internet下的应用程序事半功倍。
说过开场旁白后,首先介绍:设置系统默认浏览器和系统默认电子邮件收发软件。
1.获得默认的internet浏览器地址函数:
下面的函数是通过读取注册表的设置后,得到默认Internet的浏览器所在地址
function GetDefaultShellHTTP : string;
var
reg : TRegistry;
begin
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_CLASSES_ROOT;
if Reg.KeyExists(http\shell\open\command) then
begin
Reg.OpenKey(http\shell\open\command,false);
Result:=Reg.ReadString();
end
else
Result:=;
Reg.Free;
end;
2.设置internet浏览器
procedure SetDefaultShellHttp(CmdLine : string);
var
reg : TRegistry;
begin
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_CLASSES_ROOT; //注册表的地址:
Reg.OpenKey(http\shell\open\command,true);//注册表的地址:
Reg.WriteString(,CmdLine);
Reg.Free;
end;
setDefaultshellhttp(C:\PROGRA~1\INTERN~1\iexplorer.exe -nohome);
3.获得和设置默认的E-Mail 收发软件的函数
下面的函数是通过读取注册表的设置后,得到默认E-mail收发软件所在地址
function GetDefaultMail : string;
var
reg : TRegistry;
begin
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_CLASSES_ROOT;
if Reg.KeyExists(Mailto\shell\open\command) then
begin
Reg.OpenKey(Mailto\shell\open\command,false);
Result:=Reg.ReadString();
end
else
Result:=;
Reg.Free;
end;
4.设置默认邮件箱
procedure SetDefaultMail(CmdLine : string);
var
reg : TRegistry;
begin
Reg:=TRegistry.Create;
Reg.RootKey:=HKEY_CLASSES_ROOT;
Reg.OpenKey(Mailto\shell\open\command,true);
Reg.WriteString(,CmdLine);
Reg.Free;
end;
使用