Not a Member Yet,
Click here to Register
How do you like the new design?

ID: 390
Viewed: 2932
Added: Aug 19, 2002
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo

User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Gets the server name

Highlight all by clicking in box
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

Highlight All
Private Sub Command1_Click()
Dim l As Long
Dim dc() As Byte
Dim bufptr As Long
l = NetGetDCName(ByVal 0&, _
ByVal 0&, _
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


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.

Replying to a Comment...

Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2018 All Rights Reserved. Conditions