PureBasic Forum
https://www.purebasic.fr/english/

Tip: Automatic connect/disconnect to the Internet
https://www.purebasic.fr/english/viewtopic.php?f=12&t=4708
Page 1 of 1

Author:  BackupUser [ Wed Jan 08, 2003 4:10 am ]
Post subject:  Tip: Automatic connect/disconnect to the Internet

Code updated For 5.20+

Restored from previous forum. Originally posted by PB.

This tip (for Windows only) assumes that you have a default connection
setting for the Internet in your Dial-Up Networking folder, and that
your username/password is automatic and doesn't require typed entry.

Code:
; Connect/Disconnect from the Internet via default connection.
; By PB -- please feel free to use in any way you wish.  :)
; Note 1: Requires Win98 or higher, or Win95 with Internet Explorer 4.
; Note 2: Username and password must be "remembered" for this to work.
;
If InternetGetConnectedState_(0,0)=#True
  Debug "Already connected by another process!"
Else
  isp$="D-Link iPrimus DSL Connection" ; Default connection name.
  ConnectionID=1 ; 1 = Any number you want to identify this connection.
  If InternetDial_(0,isp$,2,@ConnectionID,0) <> #ERROR_SUCCESS
    Debug "Connection was unsuccessful..."
  Else
    Debug "Connected successfully!"
    Debug "Press SPACE when ready to disconnect..."
    GetAsyncKeyState_(#VK_SPACE) ; Clear space buffer before testing.
    Repeat : Sleep_(1) : Until GetAsyncKeyState_(#VK_SPACE)=-32767
    Debug "Disconnecting... (May take a few seconds)."
    InternetHangUp_(ConnectionID,0)
    Debug "Disconnected."
  EndIf
EndIf


Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/