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.