Kontakt
DSVGO
'API-Deklarationen: Private Declare Function NetApiBufferFree Lib "netapi32.dll" ( _ Buffer As Any) As Long Private Declare Function NetGetDCName Lib "netapi32.dll" ( _ strServerName As Any, strDomainName As Any, _ pBuffer As Long) As Long Private Declare Sub RtlMoveMemory Lib "kernel32" ( _ dest As Any, source As Any, ByVal bytes As Long) 'Routine: Public Function GetPDCName() As String Dim Ptr As Long 'Lage des Ergebnisses Static PDC As String '"Cache" (wg. Performance) 'API nur aufrufen, falls PDC bisher unbekannt: If LenB(PDC) = 0 Then If NetGetDCName(0, 0, Ptr) = 0 Then 'String anlegen (1 Zeichen mehr als nötig): PDC = String$(129, 0) 'Ergebnis in den String kopieren, Buffer freigeben: RtlMoveMemory ByVal StrPtr(PDC), ByVal Ptr, LenB(PDC) NetApiBufferFree Ptr 'String zuschneiden: PDC = Left$(PDC, InStr(PDC, vbNullChar) - 1) End If End If GetPDCName = PDC End Function
© Jost Schwider, 05.02.2001-05.02.2001 - http://vb-tec.de/getpdc.htm