BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Re: MS SQL SERVER STATUS!

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Morpheus
Guest





PostPosted: Mon May 24, 2004 6:59 am    Post subject: Re: MS SQL SERVER STATUS! Reply with quote



Hi Vahid,

Here's a unit I wrote with help from a couple of posts in this forum for
finding SQL servers on a network. Hope this helps.

unit uGetServers;

interface

uses
Windows, Classes, SysUtils;

// broadcasted so that any single unit can expose method to handle
enumerating
// their type of server
type TServerInfo101 = record
platform_id: DWORD;
name: PWideChar;
version_major: DWORD;
version_minor: DWORD;
server_type: DWORD;
comment: PWideChar;
end;

PServerInfo101 = ^TServerInfo101;

const
NERR_SUCCESS = 0;
MAX_PREFERRED_LENGTH = DWORD(-1);
SV_TYPE_WORKSTATION = $00000001;
SV_TYPE_SERVER = $00000002;
SV_TYPE_SQLSERVER = $00000004;
SV_TYPE_DOMAIN_CTRL = $00000008;
SV_TYPE_DOMAIN_BAKCTRL = $00000010;
SV_TYPE_TIME_SOURCE = $00000020;
SV_TYPE_AFP = $00000040;
SV_TYPE_NOVELL = $00000080;
SV_TYPE_DOMAIN_MEMBER = $00000100;
SV_TYPE_PRINTQ_SERVER = $00000200;
SV_TYPE_DIALIN_SERVER = $00000400;
SV_TYPE_XENIX_SERVER = $00000800;
SV_TYPE_SERVER_UNIX = SV_TYPE_XENIX_SERVER;
SV_TYPE_NT = $00001000;
SV_TYPE_WFW = $00002000;
SV_TYPE_SERVER_MFPN = $00004000;
SV_TYPE_SERVER_NT = $00008000;
SV_TYPE_POTENTIAL_BROWSER = $00010000;
SV_TYPE_BACKUP_BROWSER = $00020000;
SV_TYPE_MASTER_BROWSER = $00040000;
SV_TYPE_DOMAIN_MASTER = $00080000;
SV_TYPE_SERVER_OSF = $00100000;
SV_TYPE_SERVER_VMS = $00200000;
SV_TYPE_WINDOWS = $00400000; // Windows95 and above
SV_TYPE_DFS = $00800000; // Root of a DFS tree
SV_TYPE_CLUSTER_NT = $01000000; // NT Cluster
SV_TYPE_DCE = $10000000; // IBM DSS (Directory and Security Services) or
equivalent
SV_TYPE_ALTERNATE_XPORT = $20000000; // return list for alternate
transport
SV_TYPE_LOCAL_LIST_ONLY = $40000000; // Return local list only
SV_TYPE_DOMAIN_ENUM = $80000000;
SV_TYPE_ALL = $FFFFFFFF; // handy for NetServerEnum2

function NetServerEnum(const ServerName: PWideString;
level: DWORD;
var Buffer: pointer;
PrefMaxLen: DWORD;
var EntriesRead: DWORD;
var TotalEntries: DWORD;
ServerType: DWORD;
const Domain: PWideChar;
var ResumeHandle: DWORD): DWORD; stdcall; external
'netapi32.dll';

function NetApiBufferFree(Buffer: pointer): DWORD; stdcall; external
'netapi32.dll';

function GetServerNames(const ServerType:DWORD):TStringList;
implementation

function GetServerNames(const ServerType:DWORD):TStringList;
var
Buffer: pointer;
EntriesRead,i,ErrCode,ResumeHandle,TotalEntries: DWORD;
PDomainUnicode: PWideChar;
ServerInfo: PServerInfo101;
slServerNames: TStringList;
begin
slServerNames := TStringList.Create;
ResumeHandle := 0;

PDomainUnicode := nil;
errCode := NetServerEnum(nil, 101, Buffer, MAX_PREFERRED_LENGTH,
EntriesRead,
TotalEntries, ServerType, PDomainUnicode, ResumeHandle);

if (errCode <> NERR_SUCCESS) then
slServerNames.Add('Can''t enumerate servers!')
else begin
try
ServerInfo := Buffer;
for i := 1 to EntriesRead do
begin
slServerNames.Add(ServerInfo^.name);
Inc(ServerInfo);
end;
if slServerNames.Count = 0 then
slServerNames.Add('No servers available!');
finally
NetApiBufferFree(Buffer);
Result := slServerNames;
end; // end of try finally
end;
end;

end.

Regards,
Morpheus

"Vahid G-Karan" <gachkaran (AT) kavoshyar-iran (DOT) com> wrote

Quote:
hi all,
How can I :
1) Find MS SQL server list?
2) Get MS SQL server status (Run / Stop /etc.)?

Thanks.





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.