dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB4/32,VB5,VB6
Expertise: Intermediate
Jan 20, 2001

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


GetPDCName - The name of the Primary Domain Controller

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)

' Return the name of the Primary Domain Controller (PDC)
'
' server names are preceded by a double slash

Function GetPDCName() As String
    Dim lpBuffer As Long
    Dim buffer As String
    
    If NetGetDCName(vbNullString, vbNullString, lpBuffer) = 0 Then
        ' a zero return value means success
        buffer = Space$(128)
        ' copy into local buffer
        CopyMemory ByVal StrPtr(buffer), ByVal lpBuffer, LenB(buffer)
        ' trim excess chars
        GetPDCName = Left$(buffer, InStr(buffer & vbNullChar, vbNullChar) - 1)
        ' release memory
        NetApiBufferFree lpBuffer
    End If

End Function
Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date