如何在点击某人控件后,进入网页或发送邮件?(50分)

  • 主题发起人 主题发起人 knifepj
  • 开始时间 开始时间
K

knifepj

Unregistered / Unconfirmed
GUEST, unregistred user!
如何在点击某人控件后,进入网页或发送邮件?
如:
点击 knifepj@21.com 后,打开 邮件发送软件
 
//==============================================================================
//从注册表中找出有关系统默认浏览器的信息****************************************
//==============================================================================
function GetBrowser:string;
const Extension: array[0..3] of string = ('.HTM', '.HTML', '.SHTML', '.SHTM');
var
i: byte;
Hkey1,Hkey2: Hkey;
Typ,Taille: integer;
Temp: array[0..1024] of char;
Tempstr: string;
//****************************************************************************
procedure Arrange;
var j:word;
begin
Tempstr:=StrPas(Temp);
j:=1;
repeat
if Tempstr[j] <> '%' then Inc(j) else Delete(Tempstr,j,2);
until j>=Length(Tempstr);
RegCloseKey(Hkey2);
GetBrowser := Tempstr;
end;
begin
i:=0;
repeat
if RegOpenKeyEx(Hkey_CLASSES_ROOT, pchar(Extension), 0, KEY_ALL_ACCESS, Hkey1) = 0 then
begin
if RegQueryValueEx(Hkey1, nil, nil, @Typ, nil, @Taille) = ERROR_SUCCESS then
begin
RegQueryValueEx(Hkey1, nil, nil, nil, @Temp, @Taille);
if Temp<>'' then
if RegOpenKeyEx(Hkey_CLASSES_ROOT, pchar(Temp+'/shell/open/command'), 0, key_all_access, Hkey2) = ERROR_SUCCESS then
begin
if RegQueryValueEx(Hkey2, nil, nil, @Typ, nil, @Taille) = ERROR_SUCCESS then
begin
RegQueryValueEx(Hkey2, nil, nil, nil, @Temp, @Taille);
if Temp <> '' then
begin
Arrange;
Exit;
end;
end;
RegCloseKey(Hkey2);
end;
if RegOpenKeyEx(Hkey1, 'shell/open/command', 0, KEY_ALL_ACCESS, Hkey2) = ERROR_SUCCESS then
begin
if RegQueryValueEx(Hkey2, nil, nil, @Typ, nil, @Taille) = ERROR_SUCCESS then
begin
RegQueryValueEx(Hkey2, nil, nil, nil, @Temp, @Taille);
if Temp<>'' then
begin
Arrange;
Exit;
end;
end;
end;
end;
RegCloseKey(Hkey1);
end;
inc(i);
until i = 4;
Result := '';
end;

//==============================================================================
//检索Windows默认的Internet浏览器的执行文件名及有关参数*************************
//==============================================================================
function GetBrowserNameAndParam(var Param: string): string;
var Temp:string;
i:word;
begin
Temp:=UpperCase(GetBrowser);
if Temp<>'' then
begin
i:=Length(Temp)+1;
repeat
Dec(i);
Param:=Copy(Temp,i-3,4);
until (Param='.EXE') or (Param='.BAT') or (Param='.COM');
if i<length(Temp) then
begin
Param:=Trim(Copy(Temp,i+1,Length(Temp)-(i)));
while (Param<>'') and (Param[1]='"') do Delete(Param,1,1);
Delete(Temp,i+1,Length(Temp)-(i));
end else Param:='';
if Temp[1]='"' then Delete(Temp,1,1);
end;
Result := Temp;
end;

//==============================================================================
//执行Internet浏览器发送E_Mail及有关参数****************************************
//==============================================================================
function GotoWeb(hwnd: HWND; Kind: integer; BrowserName: string; Param: string; Address: string; nShowCmd: integer): Boolean;
begin
if BrowserName <> ''
then begin{Web:=0,EMail:=1}
if Kind=0 then Result := not (ShellExecute(hwnd, nil, PChar(BrowserName), PChar(Param + ' '+ Address), nil, nShowCmd)<33)
{shellexecute函数如返回值等于或小于32则表示发生一个错误,详细情况请参阅Win32手册}
else if Kind=1 then Result := not (ShellExecute(hwnd, nil, PChar(BrowserName), PChar(Param + ' mailto:'+ Address), nil, nShowCmd)<33)
else Result := false;
end
else Result := false;
end;

 
shellexecute(handle,PChar('OPEN'),Pchar('www.knifepj@21.com'),PChar(''),PChar(''), SW_SHOWNORMAL);
 
ghuan,
shellexecute这个函数要启用那一个文件??
 
???某人控件^^^
 
use shellApi
实现超级链接

  在程序中实现打开浏览器,打开邮件程序的功能首先要在uses部分加入
uses Shellapi;
  接着在需要超级链接的地方使用
ShellExecute(handle,nil,pchar('mailto:guihong@163.net'),nil,nil,sw_shownormal);
  其中pchar()中的mailtos是打开邮件程序的,可以换成http://、ftp://、gopher://、new:、telnet:等多种形式



 
ShellExecute(handle,nil,pchar('mailto:guihong@163.net'),nil,nil,sw_shownormal);
请问如何让
邮件上的‘主题’有内容??

如 地址:guihong@163.net
....
主题:你好!
 
那用要到smtp控件!!
参考:http://tech.sina.com.cn/c/2001-09-21/6021.html
祝你成功!
 
'mailto:guihong@163.net?subject=我的主题'
 
多人接受答案了。
 

Similar threads

D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部