Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

Embarcadero Delphi – Get Internet Connection Type

Posted on January 5, 2017 By David Kittell
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, WinInet;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
const
  MODEM = 1;
  LAN = 2;
  PROXY = 4;
  BUSY = 8;
 
function GetConnectionKind(var strKind: string): Boolean;
var
  flags: DWORD;
begin
  strKind := '';
  Result := InternetGetConnectedState(@flags, 0);
  if Result then
  begin
    if (flags and MODEM) = MODEM then strKind := 'Modem';
    if (flags and LAN) = LAN then strKind := 'LAN';
    if (flags and PROXY) = PROXY then strKind := 'Proxy';
    if (flags and BUSY) = BUSY then strKind := 'Modem Busy';
  end;
end;
 
{$R *.dfm}
 
procedure TForm1.FormCreate(Sender: TObject);
var
  strKind: string;
begin
  if GetConnectionKind(strKind) then
    ShowMessage(strKind);
 
end;
 
end.
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.

Related

Code Delphi

Post navigation

Previous post
Next post

Related Posts

Unix Shell – Set/Change IP

Posted on October 19, 2015October 19, 2015

By default UNIX computers/servers are setup with a DHCP/Dynamic IP address, below is how to change the IP to static Before you do either process understand what these settings should be: Network Interace you plan to modify (eth0, eth1, etc.) IP Address (address) Subnet Mask (netmask) Default Gateway (gateway) Whether…

Read More

Check For Valid Date

Posted on February 28, 2013October 26, 2015

Recently I had to validate dates in a form specifically the date of visit and date of birth This function will now check both for future date and do more checks for the date of visit, debug/helper information left in to better understand the function. Function Code: public bool bCheckDate(string…

Read More

Bash – Rename Picture

Posted on November 15, 2022August 17, 2024

for f in *.HEIC; do mv -v "$f" "${f%.HEIC}.heic" done # 1 set -eu -o pipefail # 2 count=$(find . -depth 1 -name "*.heic" | wc -l | sed ‘s/[[:space:]]*//’) echo "converting $count files .heic files to .jpg" # 3 magick mogrify -monitor -format jpg *.heic # 4 echo "Remove…

Read More

Code

Top Posts & Pages

  • PowerShell - Install .NET 4.5.2
  • Front Page
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - Get Text Encoding Type
  • PowerShell - Rename Pictures to Image Taken

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Install .NET 4.5.2
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - Get Text Encoding Type
  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - UNIX SED Equivalent - Change Text In File
  • PowerShell - Java JDK/JRE Unattended Install
©2025 David Kittell | WordPress Theme by SuperbThemes
David Kittell
  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support