How to obtain the name of the current netbios workgroup?
How to obtain the name of the current netbios workgroup?
How can I obtain information about the current workgroup and domain for the current user?
Re: How to obtain the name of the current netbios workgroup?
Mistrel wrote:How can I obtain information about the current workgroup and domain for the current user?
Code: Select all
RunProgram("wmic", "computersystem get workgroup, domain", "")
Re: How to obtain the name of the current netbios workgroup?
I mean with Win32 and library calls. Not the output from a console program.
Re: How to obtain the name of the current netbios workgroup?
Tested succcessfully on Window 10 x64 V1809 with PB 5.46 in ASCII and Unicode mode and PB 5.71 (with 32-bit and 64-bit compilation):
Code: Select all
EnableExplicit
#ComputerNameDnsDomain = 2
Enumeration NETSETUP_JOIN_STATUS
#NetSetupUnknownStatus
#NetSetupUnjoined
#NetSetupWorkgroupName
#NetSetupDomainName
EndEnumeration
Import ""
GetComputerNameExA(NameType.I, *Buffer, *BufferSize)
EndImport
Prototype.I NetGetJoinInformation(Host.P-Unicode, *Buffer, BufferType.I)
Define BufferSize.I
Define *DomainBuffer
Define Info.S
Define JoinInfo.NetGetJoinInformation
Define JoinStatus.I
Define *NameBuffer
If InitNetwork()
If OpenLibrary(0, "NetAPI32.DLL")
JoinInfo = GetFunction(0, "NetGetJoinInformation")
If JoinInfo
If JoinInfo(ComputerName(), @*NameBuffer, @JoinStatus) = 0
Select JoinStatus
Case #NetSetupUnknownStatus
Info = "Unknown network status!"
Case #NetSetupUnjoined
Info = "Not joined to any workgroup or domain!"
Case #NetSetupWorkgroupName
Info = "Joined to the workgroup " +
PeekS(*NameBuffer, -1, #PB_Unicode)
Case #NetSetupDomainName
; ----- Doesn't display top level domain, for example local in
; xxx.local
; Info = "Joined to the domain " +
; PeekS(*NameBuffer, -1, #PB_Unicode)
; ----- Display second level domain plus top level domain
GetComputerNameExA(#ComputerNameDnsDomain, 0, @BufferSize)
If BufferSize
*DomainBuffer = AllocateMemory(BufferSize)
If GetComputerNameExA(#ComputerNameDnsDomain, *DomainBuffer,
@BufferSize)
Info = "Joined to the domain " +
PeekS(*DomainBuffer, -1, #PB_Ascii)
EndIf
FreeMemory(*DomainBuffer)
EndIf
EndSelect
EndIf
EndIf
NetApiBufferFree_(*NameBuffer)
CloseLibrary(0)
MessageRequester("Detect if joined to domain or workgroup",
Info,
#MB_ICONINFORMATION)
EndIf
EndIf
Re: How to obtain the name of the current netbios workgroup?
That's it. Thank you.