|
-
January 26th, 2000, 02:09 AM
#1
Get Server Name
Hi!
How can I get the servername?
I guess it is with an API but can't find the right one.
Thanks in advance
jen
-
January 26th, 2000, 02:15 AM
#2
Re: Get Server Name
what kind of server are you trying to get?
- NetServerEnum allows you to enumerate all
servers.
- NetGetDCName retrieves the name of the domain controller
-
January 26th, 2000, 05:09 AM
#3
Re: Get Server Name
Hi Lothar and thanks for your quick answer!
I want the Domain Controller but when I search my Win32 via API viewer I can't find this api. What am I doing wrong?
(I'm using NT 4.0)
jen
-
January 26th, 2000, 05:21 AM
#4
Re: Get Server Name
>What am I doing wrong?
Nothing. the API Viewer does not list that function.
option Explicit
private Declare Function lstrlenW Lib "kernel32" (byval lpString as Long) as Long
private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination as Any, Source as Any, byval Length as Long)
private Declare Function NetGetDCName Lib "Netapi32.dll" (strServer as Any, strDomain as Any, bufptr as Long) as Long
private Declare Function NetApiBufferFree Lib "Netapi32.dll" (byval lpBuffer as Long) as Long
private Sub Command1_Click()
Dim l as Long
Dim dc() as Byte
Dim bufptr as Long
l = NetGetDCName(byval 0&, _
byval 0&, _
bufptr)
MsgBox Pointer2stringw(bufptr)
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
parts of that code abopted from Karl Peterson...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|