DFÜ-Verbindung herstellen und beenden |
|
| System | Win9x, WinNT, Win2000, WinXP, Vista, Win7 |
|---|---|
| Ab Delphi-Version | Delphi 1 |
| Letzte Änderung | 28.09.2010 |
Mit folgende Funktionen kann eine DFÜ-Verbindung hergestellt undbeendet werden:Der erste Parameter ist der Name der DFÜ-Verbindung,der zweite liefert den Error-Code, der dritte eineID-Nummer die man beim beenden der DFÜ-Verbindung mit angeben muss. (ConID)Konnte eine Verbindung aufgebaut werden, wird true zurück geliefert,sonst false.Die Funktion beendet erst wenn die Verbindung steht.(jedenfalls bei mir: Win Me/98)
uses WinInet;
{ INTERNET_AUTODIAL_FORCE_ONLINE -> Forces an online connection.
INTERNET_AUTODIAL_FORCE_UNATTENDED -> Forces an unattended Internet dial-
up. If user intervention is required, the function will fail.
INTERNET_DIAL_FORCE_PROMPT -> Ignores the "dial automatically" setting and
forces the dialing user interface to be displayed.
INTERNET_DIAL_UNATTENDED -> Connects to the Internet through a modem,
without displaying a user interface, if possible. Otherwise, the function will
wait for user input.
INTERNET_DIAL_SHOW_OFFLINE -> Shows the Work Offline button instead of
Cancel button in the dialing user interface. }
function DialDFUE(DFUEName : String; var ErrorCode : integer; var ConId :
DWord) : boolean;
var ConNum : LPDWORD;
ReturnCode : DWord;
begin
result := false;
ErrorCode := 0;
New(ConNum);
try
ReturnCode := InternetDial(Application.Handle , PChar(DFUEName),
INTERNET_AUTODIAL_FORCE_UNATTENDED, ConNum, 0);
{Returns ERROR_SUCCESS if successful, or an error value otherwise. The
error code can be one of the following:
ERROR_INVALID_PARAMETER One or more of the parameters are incorrect.
ERROR_NO_CONNECTION There is a problem with the dial-up connection.
ERROR_USER_DISCONNECTION The user clicked either the Work Offline or
Cancel button on the Internet connection dialog box.}
ErrorCode := ReturnCode;
if ReturnCode = ERROR_SUCCESS then
begin
result := true;
ConId := ConNum^;
end;
finally
Dispose(ConNum);
end;
end;
Zum Beenden einer DFÜ-Verbindung folgende Funktionbenutzen: (Die Funktion ist in WinInt implementiert)
InternetHangUp(ConID, 0);