- Yasaklandı
- #1
Aşağıdaki class ağda kurulu SQL Server'in var olup olmadığını bulur:
Visual Basic:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "ListServers"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Private Declare Function lstrlenW Lib "kernel32" _
(ByVal lpString As Long) As Long
Private Declare Function NetServerEnum Lib "netapi32" ( _
strServername As Any, _
ByVal level As Long, _
bufptr As Long, _
ByVal prefmaxlen As Long, _
entriesread As Long, _
totalentries As Long, _
ByVal servertype As Long, _
strDomain As Any, _
resumehandle As Long) As Long
Private Declare Function NetApiBufferFree Lib "Netapi32.dll" _
(ByVal lpBuffer As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
Private Const SV_TYPE_SERVER As Long = &H2
Private Const SV_TYPE_SQLSERVER As Long = &H4
Private m_results As New Collection
Private m_Domain As String
Private Type SV_100
platform As Long
name As Long
End Type
Public Property Get Servers() As Collection
Set Servers = m_results
End Property
Public Property Let Domain(ByVal vData As String)
m_Domain = vData
End Property
Public Property Get Domain() As String
Domain = m_Domain
End Property
Public Sub GetSQLServers()
Dim l As Long
Dim entriesread As Long
Dim totalentries As Long
Dim hREsume As Long
Dim bufptr As Long
Dim level As Long
Dim prefmaxlen As Long
Dim lType As Long
Dim Domain() As Byte
Dim i As Long
Dim sv100 As SV_100
level = 100
prefmaxlen = -1
lType = SV_TYPE_SQLSERVER
Domain = m_Domain & vbNullChar
l = NetServerEnum(ByVal 0&, _
level, _
bufptr, _
prefmaxlen, _
entriesread, _
totalentries, _
lType, _
Domain(0), _
hREsume)
If l = 0 Or l = 234& Then
For i = 0 To entriesread - 1
CopyMemory sv100, ByVal bufptr, Len(sv100)
m_results.Add (Pointer2stringw(sv100.name))
bufptr = bufptr + Len(sv100)
Next i
End If
NetApiBufferFree bufptr
End Sub
Private Function Pointer2stringw(ByVal l As Long) As String
Dim buffer() As Byte
Dim nLen As Long
'
nLen = lstrlenW(l) * 2
If nLen Then
ReDim buffer(0 To (nLen - 1)) As Byte
CopyMemory buffer(0), ByVal l, nLen
Pointer2stringw = buffer
End If
End Function
[CENTER]
formda command1 e basılınca listbox a bulunan sql[/CENTER]
serverları yazdırmak istiosan click eventine sunlari yazmalisin:
Visual Basic:
Dim oSqlUtils As New SQLUtils.ListServers
oSqlUtils.Domain = Text1.Text
oSqlUtils.GetSQLServers
For Each svr In oSqlUtils.Servers
List1.AddItem (svr)
Next
Not: Bu Aralar site hack işine girdiğimden sql üzeri konular açmaya başlıyacam konu çalıntı değil bişe değil İyi Forumlar