W wzisme Unregistered / Unconfirmed GUEST, unregistred user! 2001-10-12 #1 就像天网等防火墙等一样 随时断开/连接internet
I iamfly Unregistered / Unconfirmed GUEST, unregistred user! 2001-10-12 #2 这个问题有相关的讨论的,请看: http://www.delphibbs.com/delphibbs/dispq.asp?LID=504706
G gangfeng Unregistered / Unconfirmed GUEST, unregistred user! 2001-11-03 #4 {* * * * * * * * * * * * * *拨号核心程序 * * * * * * * * * * * * * * * * * * * * * * * * *} // function TDialer.Dial(EntryName, UserName, Password : String):Boolean; var rdParams : TRASDIALPARAMS; dwRet : DWORD; Buf : array [0..255] of Char; begin Result := false; // setup RAS Dial Parameters FillChar(rdParams, SizeOf(rdParams), 0); rdParams.dwSize := SizeOf(TRASDIALPARAMS); strCopy(rdParams.szUserName, PChar(UserName)); strCopy(rdParams.szPassword, PChar(Password)); strCopy(rdParams.szEntryName, PChar(EntryName)); rdParams.szPhoneNumber[0] := #0; rdParams.szCallbackNumber[0] := '*'; rdParams.szDomain := '*'; //g_hWnd := Handle; hRasConn := 0;; dwRet := RasDialA(nil, nil, @rdParams, 0, nil, @hRasConn); if dwRet <> 0 then begin RasGetErrorStringA(dwRet, @Buf[0], SizeOf(Buf)); exit; //Disconnected; end; result:=true; end; //断开连接 procedure TDialer.Disconnected; begin if hRasConn <> 0 then begin RasHangUpA(hRasConn); hRasConn := 0; end; end; //程序启动自动拨号 function TDialer.AutoDial : Boolean; var IniFile : TIniFile; aEntryName : String; aUserName : String; aPassword : String; EntryName : string; UserName : string; FIniFileName : String; rdParams : TRASDIALPARAMS; dwRet : DWORD; Buf : array [0..255] of Char; begin Result := False; FIniFileName := Copy(Application.ExeName, 1, Length(Application.ExeName) - 3) + 'ini'; IniFile := TIniFile.Create(FIniFileName); try aEntryName := IniFile.ReadString('Last', 'EntryName', ''); aUserName := IniFile.ReadString('Last', 'UserName', ''); EntryName := CrunchName(Trim(aEntryName)); UserName := CrunchName(Trim(aUserName)); aPassword := IniFile.ReadString('RAS_ENTRY_' + EntryName, 'USER_' + UserName, '*'); finally IniFile.Free; end; //Result := Dial(aEntryName,aUserName,aPassword); FillChar(rdParams, SizeOf(rdParams), 0); rdParams.dwSize := SizeOf(TRASDIALPARAMS); strCopy(rdParams.szUserName, PChar(aUserName)); strCopy(rdParams.szPassword, PChar(aPassword)); strCopy(rdParams.szEntryName, PChar(aEntryName)); rdParams.szPhoneNumber[0] := #0; rdParams.szCallbackNumber[0] := '*'; rdParams.szDomain := '*'; //g_hWnd := Handle; hRasConn := 0;; dwRet := RasDialA(nil, nil, @rdParams, 0, nil, @hRasConn); if dwRet <> 0 then begin RasGetErrorStringA(dwRet, @Buf[0], SizeOf(Buf)); exit; //Disconnected; end; Result := True; end; //读取拨号网络电话本 function TDialer.LoadPhoneBook : Boolean; var Entries : array [0..15] of TRASENTRYNAME; cb : DWORD; cEntries : DWORD; dwRet : DWORD; Buf : array [0..127] of char; I : Integer; begin Result := False; setlength(PhoneBookName,20); FillChar(Entries, SizeOf(Entries), 0); Entries[0].dwSize := SizeOf(TRASENTRYNAME); cb := SizeOf(Entries); cEntries := 0; dwRet := RasEnumEntriesA(NIL, NIL, @Entries[0], @cb, @cEntries); if dwRet <> 0 then begin RasGetErrorStringA(dwRet, @Buf[0], SizeOf(Buf)); exit; //LogMessage(Buf); end else begin Result := True; PhoneBookNumber := cEntries; for I := 0 to cEntries - 1 do PhoneBookName := Entries.szEntryName; end; end;
{* * * * * * * * * * * * * *拨号核心程序 * * * * * * * * * * * * * * * * * * * * * * * * *} // function TDialer.Dial(EntryName, UserName, Password : String):Boolean; var rdParams : TRASDIALPARAMS; dwRet : DWORD; Buf : array [0..255] of Char; begin Result := false; // setup RAS Dial Parameters FillChar(rdParams, SizeOf(rdParams), 0); rdParams.dwSize := SizeOf(TRASDIALPARAMS); strCopy(rdParams.szUserName, PChar(UserName)); strCopy(rdParams.szPassword, PChar(Password)); strCopy(rdParams.szEntryName, PChar(EntryName)); rdParams.szPhoneNumber[0] := #0; rdParams.szCallbackNumber[0] := '*'; rdParams.szDomain := '*'; //g_hWnd := Handle; hRasConn := 0;; dwRet := RasDialA(nil, nil, @rdParams, 0, nil, @hRasConn); if dwRet <> 0 then begin RasGetErrorStringA(dwRet, @Buf[0], SizeOf(Buf)); exit; //Disconnected; end; result:=true; end; //断开连接 procedure TDialer.Disconnected; begin if hRasConn <> 0 then begin RasHangUpA(hRasConn); hRasConn := 0; end; end; //程序启动自动拨号 function TDialer.AutoDial : Boolean; var IniFile : TIniFile; aEntryName : String; aUserName : String; aPassword : String; EntryName : string; UserName : string; FIniFileName : String; rdParams : TRASDIALPARAMS; dwRet : DWORD; Buf : array [0..255] of Char; begin Result := False; FIniFileName := Copy(Application.ExeName, 1, Length(Application.ExeName) - 3) + 'ini'; IniFile := TIniFile.Create(FIniFileName); try aEntryName := IniFile.ReadString('Last', 'EntryName', ''); aUserName := IniFile.ReadString('Last', 'UserName', ''); EntryName := CrunchName(Trim(aEntryName)); UserName := CrunchName(Trim(aUserName)); aPassword := IniFile.ReadString('RAS_ENTRY_' + EntryName, 'USER_' + UserName, '*'); finally IniFile.Free; end; //Result := Dial(aEntryName,aUserName,aPassword); FillChar(rdParams, SizeOf(rdParams), 0); rdParams.dwSize := SizeOf(TRASDIALPARAMS); strCopy(rdParams.szUserName, PChar(aUserName)); strCopy(rdParams.szPassword, PChar(aPassword)); strCopy(rdParams.szEntryName, PChar(aEntryName)); rdParams.szPhoneNumber[0] := #0; rdParams.szCallbackNumber[0] := '*'; rdParams.szDomain := '*'; //g_hWnd := Handle; hRasConn := 0;; dwRet := RasDialA(nil, nil, @rdParams, 0, nil, @hRasConn); if dwRet <> 0 then begin RasGetErrorStringA(dwRet, @Buf[0], SizeOf(Buf)); exit; //Disconnected; end; Result := True; end; //读取拨号网络电话本 function TDialer.LoadPhoneBook : Boolean; var Entries : array [0..15] of TRASENTRYNAME; cb : DWORD; cEntries : DWORD; dwRet : DWORD; Buf : array [0..127] of char; I : Integer; begin Result := False; setlength(PhoneBookName,20); FillChar(Entries, SizeOf(Entries), 0); Entries[0].dwSize := SizeOf(TRASENTRYNAME); cb := SizeOf(Entries); cEntries := 0; dwRet := RasEnumEntriesA(NIL, NIL, @Entries[0], @cb, @cEntries); if dwRet <> 0 then begin RasGetErrorStringA(dwRet, @Buf[0], SizeOf(Buf)); exit; //LogMessage(Buf); end else begin Result := True; PhoneBookNumber := cEntries; for I := 0 to cEntries - 1 do PhoneBookName := Entries.szEntryName; end; end;