打印本文 打印本文 关闭窗口 关闭窗口
谈Delphi下Internet的编程技巧(一)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数2072  更新时间:2009/4/23 18:38:25  文章录入:mintao  责任编辑:mintao

谈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;

使用

//SetDefaultMail(''''E:\FoxMail\FoxMail.exe -T "%1" -S "%2"'''');

 

 

 

 

5.是否早想有个域名转换为IP地址的函数,现在我就给你一个

域名转换为IP地址:

 

function GetIPName(Name: string): string;

var

[1] [2]  下一页

打印本文 打印本文 关闭窗口 关闭窗口