200分求一禁止在windows98拨号连接拨特定的号码(如163,169)的方法。(200分)

  • 主题发起人 主题发起人 kinglaw
  • 开始时间 开始时间
我去看看
 
两种思路,一是:屏蔽掉拨号网络,然后用RAS函数自己设计拨号程序,或用WINEXEC。
二是用RAS函数做一个后台程序监测拨号过程,如果发现拨号参数中有169或163就自动
断开。
 
具体方法?
 
是呀,具体如何做呀
 
  interface
  uses
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   StdCtrls, DdeMan;
  type
   TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
   private
    { Private declarations }
  public
    { Public declarations }
   end;
  var
   Form1: TForm1;
  implementation
   uses rasapi;
  {$R *.DFM}
  procedure TForm1.Button1Click(Sender: TObject);
  var
     bufsize: Cardinal;
     numEntries: Cardinal;
     x: Integer;
     entries: Array[1..10] of TRasConn;//拨号连接数组(假设最多有10个活动的拨号连接)
     stat: TRasConnStatus;
     hRas: HRasConn;
     conexion:pRasConn;
   begin
    entries[1].dwSize := SizeOf(TRasConn);
    bufsize := SizeOf(TRasConn) * 10;
    FillChar(stat, Sizeof(TRasConnStatus), 0);
    stat.dwSize := Sizeof(TRasConnStatus);
    if RasEnumConnections(@entries[1], bufsize, numEntries) = 0 then
     begin
      if numEntries > 0 then
       with entries[1] do
       begin
        conexion:=Pointer(rasconn);
        hRas := Longint(conexion);
        if RasHangUp(hRas) <> 0 then
         ShowMessage('断开失败');
       end
       else
        ShowMessage('断开成功');
       end;
   end;


  unit rasapi;
  interface
   Uses WinTypes, WinProcs, Dialogs;
   Const
   UNLEN = 256;
   PWLEN = 256;
   DNLEN = 15;
   RAS_MaxEntryName   = 256;//连接名称最大长度
   RAS_MaxDeviceName   = 128;//设备名称最大长度
   RAS_MaxDeviceType   = 16;//设备类型名称长度
   { RAS_MaxParamKey   = 32;
   RAS_MaxParamValue   = 128;}
   RAS_MaxPhoneNumber  = 128;//电话号码的最大长度
   RAS_MaxCallbackNumber = RAS_MaxPhoneNumber;
   Type
   {UINT = Word;}
   PHRASConn = ^HRASConn;
   Type
   { 确认一活动的拨号连接. (为RasConnectEnum函数使用) }
   PRASConn = ^TRASConn;//拨号连接的句柄类型
   TRASConn = record
     dwSize: DWORD;//该结构类型所占内存的字节大小
     rasConn: HRASConn;//活动连接的句柄
     szEntryName: Array[0..RAS_MaxEntryName] Of Char;//
     szDeviceType : Array[0..RAS_MaxDeviceType] Of Char;
     szDeviceName : Array [0..RAS_MaxDeviceName] of char;
   end;

   PRASConnStatus = ^TRASConnStatus;
   TRASConnStatus = Record
     dwSize: LongInt;
     rasConnstate: Word;
     dwError: LongInt;
     szDeviceType: Array[0..RAS_MaxDeviceType] Of Char;
     szDeviceName: Array[0..RAS_MaxDeviceName] Of Char;
   End;
   PRASDIALEXTENSIONS= ^TRASDIALEXTENSIONS;
   TRASDIALEXTENSIONS= Record
     dwSize: DWORD;
     dwfOptions: DWORD;
     hwndParent: HWnd;
     reserved: DWORD;
    end;

   PRASDialParams = ^TRASDialParams;
   TRASDialParams = Record
     dwSize: DWORD;
     szEntryName: Array[0..RAS_MaxEntryName] Of Char;
     szPhoneNumber: Array[0..RAS_MaxPhoneNumber] Of Char;
     szCallbackNumber: Array[0..RAS_MaxCallbackNumber] Of Char;
     szUserName: Array[0..UNLEN] Of Char;
     szPassword: Array[0..PWLEN] Of Char;
     szDomain: Array[0..DNLEN] Of Char;
   end;
   PRASEntryName = ^TRASEntryName;
   TRASEntryName = Record
     dwSize: LongInt;
     szEntryName: Array[0..RAS_MaxEntryName] Of Char;
   {  Reserved: Byte;}
   End;

  //拨号函数
   Function RasDial(
     lpRasDialExtensions : PRASDIALEXTENSIONS ; //在WIN9X下无用,可设置为NIL
     lpszPhonebook: PChar; //在WIN9X下无用,可设置为NIL
     lpRasDialParams : PRASDIALPARAMS; // 拨号参数,类型指针
     dwNotifierType : DWORD;   { 消息通知方式}
     lpvNotifier: DWORD;    { 消息处理事件}
     var rasConn: HRASConn     { 返回成功连接的连接句柄}
    ): DWORD; stdcall;

   function RasEnumConnections(RASConn: PrasConn;
            var BufSize: DWord;
         var Connections: DWord
                 ): LongInt; stdcall;
   Function RasEnumEntries (
     reserved: PChar;    {保留字段,必须为空}
     lpszPhonebook: PChar ;    { 电话本名称,在WIN9X下无用,可设置为NIL}
     lprasentryname: PRASENTRYNAME ; {接收拨号连接名称的缓冲区,是一类型数组的指针}
     var lpcb :     DWORD; {接收拨号连接名称的缓冲区的大小}
     var lpcEntries : DWORD  {实际获得拨号连接 的数目}
    ) : DWORD; stdcall;
   function RasGetConnectStatus(RASConn: hrasConn;    { 指定活动连接的句柄 }
           RASConnStatus: PRASConnStatus { 获取活动连接状态信息的缓冲区}
                 ): LongInt; stdcall;
   function RasGetErrorString(ErrorCode: DWord;    { 错误代码标识}
                szErrorString: PChar;    { 错误提示信息的缓冲区}
                BufSize: DWord   {错误提示信息的缓冲区的大小 }
                ): LongInt; stdcall;
   function RasHangUp(RASConn: hrasConn ): LongInt; stdcall;
   function RasGetEntryDialParams(
     lpszPhonebook:PChar;    {电话本名称,在WIN9X下无用,可设置为NIL }
     VAR lprasdialparams:TRASDIALPARAMS; {拨号参数,是一类型指针}
     VAR lpfPassword : BOOL    {显示是否需要用户密码}
    ): DWORD; stdcall;

   implementation
   const
   RAS_DLL = 'RASAPI32';
   function RasDial; external RAS_DLL name 'RasDialA';
   function RasEnumConnections; external RAS_DLL name 'RasEnumConnectionsA';
   function RasEnumEntries; external RAS_DLL name 'RasEnumEntriesA';
   function RasGetConnectStatus; external RAS_DLL name 'RasGetConnectStatusA';
   function RasGetErrorString; external RAS_DLL name 'RasGetErrorStringA';
   function RasHangUp; external RAS_DLL name 'RasHangUpA';
   function RasGetEntryDialParams; external RAS_DLL name 'RasGetEntryDialParamsA';
  end.

 
接受答案了.
 
后退
顶部