首页 | 社区 | 博客 | 招聘 | 文章 | 新闻 | 下载 | 项目交易 | 网友作品 | 读书 | ACM题库 | 源码
亲,您未登录哦! 登录 | 注册

取当前所有的拨号连接的程式

(加入日期: 2001-07-23 )

打印文章】【字体:

分享到:
{+++++++++++++++++++++++
  取当前所有的拨号连接的程式;
  参数为传入的列表,过程成功为参数付值且返回值为真
  否则为假;
  调用方法类似
  if GetEntries(Memo1.Lines) then
  begin
  end
  else
  begin
  end;
Date:2001/03/07  12:30-----13:32
Remark:
+++++++++++++++++++++++++++++++++++++++++++++++++++++
}
function TForm1.GetEntries(List: TStrings):Boolean;
type
  TRasEntryName = record
    Size : DWORD;
    EntryName:  array[0..256] of Char;
  end;

  TRasEnumEntries =  function(Reserved : Pointer;
                              PhoneBook : Pointer;
                              RasEntryName : Pointer;
                              var cb : DWORD;
                              var Entries : DWORD) : DWORD; stdcall;

const
  RasAPI32='RASAPI32.dll';

var
  FRasLibHandle : THandle;
  RasEntries : array[1..25] of TRasEntryName;
  Size : DWORD;
  Count : DWORD;
  i : DWORD;
  RasEnumEntries : TRasEnumEntries;
begin
//  if List=Nil then Exit;
try
    List.Clear;

    FRasLibHandle:=LoadLibrary(RasAPI32);
    try
      if FRasLibHandle=0 then Exit;

    { 获取RasEnumEntriesA方法地址;本方法的关键是对RASAPI32.dll提供的方法要
      熟悉,利用API过程GetProcAddress来取DLL中的方法地址,给方法指针付值后
      调用,其它如拨号程式,
      TRasDial =  function(RasDialExtensions : Pointer;
                            PhoneBook : Pointer;
                            var RasDialParams : TRasDialParams;
                            NotifierType : DWORD;
                            Notifier : Pointer;
                            var RasConn : THandle) : DWORD; stdcall;

      @RasDial:=GetProcAddress(FRasLibHandle,'RasDialA');
      拨号后挂起程式
      TRasHangUp =  function(RassCon : THandle) : DWORD; stdcall;
      @RasHangUp:=GetProcAddress(FRasLibHandle,'RasHangUpA');
    类同}
      @RasEnumEntries:=GetProcAddress(FRasLibHandle,'RasEnumEntriesA');
      if @RasEnumEntries=nil then Exit;

      RasEntries[1].Size:=SizeOf(TRasEntryName);
      Size:=SizeOf(RasEntries);
      if RasEnumEntries(nil,nil,@RasEntries,Size,Count)=0 then
      begin
        for i:=1 to Count do
          List.Add(RasEntries[i].EntryName);
      end;
      Result:=True;
    finally
      FreeLibrary(FRasLibHandle);
    end;
except
end;

end; 

本栏文章均来自于互联网,版权归原作者和各发布网站所有,本站收集这些文章仅供学习参考之用。任何人都不能将这些文章用于商业或者其他目的。( Pfan.cn )

编程爱好者论坛

本栏最新文章