Funkce:
Private Declare Function NetGetDCName Lib "netapi32.dll" _
(strServerName As Any, strDomainName As Any, pBuffer As
Long) As Long
Private Declare Function NetApiBufferFree Lib "netapi32.dll" _
(buffer As Any) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory"
_
(dest As Any, source As Any, ByVal bytes As Long)
Function GetPDCName() As String
Dim lpBuffer As Long
Dim buffer As String
If NetGetDCName(vbNullString, vbNullString, lpBuffer) = 0
Then
buffer = Space$(128)
CopyMemory ByVal StrPtr(buffer),
ByVal lpBuffer, LenB(buffer)
GetPDCName = Left$(buffer, InStr(buffer
& vbNullChar, vbNullChar) - 1)
NetApiBufferFree lpBuffer
End If
End Function
|