ADO Database Delphi

Title: Find all MSSQL Server actual available
Question: How is it possible to get a list of all active MSSQL server actual on network.
Answer:
In addition of the article 2385 of Tommy Andersen and sample of SQL-Ping from Chip Anderson, Michael Choi and Rajiv Delwadia "http://www.sqlsecurity.com". This little program runs without any additional like SQL-DMO or else. It is very quickly and look over domain ranges.
You need a Button and a listbox on the form for this sample.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Winsock, StdCtrls, ScktComp;
Const
CM_SocketCallBack = WM_App + 600;
type
TClearSocketThread = class(TThread)
private
waitTime:Integer;
socket:Integer;
protected
procedure Execute; override;
public
constructor Create(s,w:Integer);
end;
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
Procedure CMSocketCallBack(Var Msg: TMessage); Message CM_SocketCallBack;
public
s:Integer;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
constructor TClearSocketThread.Create(s,w:Integer);
begin
Socket:=s;
waitTime:=w;
FreeOnTerminate:=true;
inherited create(false);
end;
procedure TClearSocketThread.Execute;
begin
sleep(waitTime);
closesocket(Socket);
WSACleanup;
windows.beep(4000,100);
end;
Procedure TForm1.CMSocketCallBack(Var Msg: TMessage);
var
buffer:array [0..64000] of char;
str:String;
n:Integer;
begin
fillchar(buffer,64000,0);
recv(s,buffer,sizeof(buffer),0);
str:='';
for n:=3 to 64000 do begin
if buffer[n]=';' then begin
Listbox1.Items.Add(str);
str:='';
continue;
end;
if buffer[n]=#0 then begin
Listbox1.Items.Add(str);
break;
end;
str:=str+buffer[n];
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
const
Address='255.255.255.255';
var
wsa_data:WSADATA;
SNDBUF:Integer;
TCPNODELAY:Integer;
BROADCAST:integer;
hostaddr: sockaddr_in;
buf:char;
begin
Listbox1.items.clear;
WSAStartup(2,wsa_data);
//create a socket
s:=socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
//declare call back routine
WSAAsyncSelect(s,self.Handle,CM_SocketCallBack,FD_READ);
//setup
SNDBUF:=0;
TCPNODELAY:=1;
BROADCAST:=1;
setsockopt(s,SOL_SOCKET,SO_SNDBUF,PChar(@SNDBUF),sizeof(SNDBUF));
setsockopt(s,SOL_SOCKET,TCP_NODELAY,PChar(@TCPNODELAY),sizeof(TCPNODELAY));
setsockopt(s,SOL_SOCKET,SO_BROADCAST,PChar(@BROADCAST),sizeof(BROADCAST));
hostaddr.sin_family :=AF_INET;
hostaddr.sin_port :=htons(1434);
hostaddr.sin_addr.s_addr:=inet_addr(PChar(Address));
buf:=#02; //ping
//ask all maschines
sendto(s,buf,1,0,hostaddr,sizeof(hostaddr));
TClearSocketThread.Create(s,5000);
end;
end.