求WIN7系统用的PPPOE ADSL拨号和挂断代码解决方案

求WIN7系统用的PPPOE ADSL拨号和挂断代码
以前用XP系统的 总结出一段拨号和挂断代码
虽然在别人的电脑不是百分百地有效 但是效果还是有的

现在换了win7系统 发现挂断有效 但拨号功能已经失败了
WIN7系统中手工ADSL拨号速度也非常慢(跟XP对比)
一些要换IP的网络程序也写不了

现在求一段WIN7可用的拨号代码 谢谢
附以前的XP可用代码:
Delphi(Pascal) code


var
  BH: Cardinal;

function Dial(out aBH: Cardinal): Boolean;
begin
  Result := False;
  if InternetDial(0, nil, INTERNET_DIAL_UNATTENDED, @aBH, 0) = 0 then
    if aBH > 0 then
    begin
      Form1.Label_IP.Caption := GetInternetlIP;
      Result := True;
    end;
end;

function HangUp(aBH: Cardinal): Boolean;
begin
  Result := False;
  if aBH = 0 then
  begin
    if WinExec('rasdial.exe /disconnect', 0) = 33 then
      Result := True;
  end else
  begin
    if InternetHangUp(aBH, 0) = 0 then
      Result := True;
  end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  Dial(BH);    //拨号
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  HangUp(BH);   //挂断
end;



------解决方案--------------------
Delphi(Pascal) code

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, WinInet, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  lpdwConnection :DWord;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  Res:Cardinal;
begin
  Res:=InternetDial(Handle,PChar('ADSL'),INTERNET_DIAL_UNATTENDED,@lpdwConnection,0);
  ShowMessage(IntToStr(Res));      //返回值为0时则连接成功
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  InternetHangUp(lpdwConnection,0);
end;

end.