1. Home
  2. Computing & Technology
  3. Delphi Programming

Connect and disconnect to/from the Internet

By , About.com Guide

Here's how to connect to the Internet from Delphi code:

InternetAutoDial(dwFlags, hwndParent) ;

Where dwFlags can be one of the following values:
INTERNET_AUTODIAL_FAILIFSECURITYCHECK - causes InternetAutodial to fail if file and printer sharing is disabled for Microsoft® Windows® 95 or later.
INTERNET_AUTODIAL_FORCE_ONLINE - forces an online Internet connection.
INTERNET_AUTODIAL_FORCE_UNATTENDED - forces an unattended Internet dial-up.
and, hwndParent is Handle to the parent window.

Exmaple:

~~~~~~~~~~~~~~~~~~~~~~~~~
uses WinInet;
...
InternetAutoDial(internet_autodial_force_unattended, Handle) ;

{
To disconnect this automatic dial-up connection, use
}

InternetAutodialHangup(0)

{
Another way is to specify the name
of the connection you wish to use
(ConnectionName), from Dialup
networking:
}

if InternetDial
    (0, PChar(ConnectionName), INTERNET_AUTODIAL_FORCE_UNATTENDED, dwConn, 0) <> ERROR_SUCCESS then exit;
//Do something with Internet...
InternetHangup(dwConn, 0) ;
~~~~~~~~~~~~~~~~~~~~~~~~~

Delphi tips navigator:
» How to correctly use the mouse wheel in TDBGrid
« How to Convert a String of Integers into an Array of Byte

Explore Delphi Programming
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. Delphi Tips and Tricks
  6. 2002 Delphi Tips
  7. Connect and disconnect to/from the Internet

©2009 About.com, a part of The New York Times Company.

All rights reserved.