Don’t fool with pinvoke if you don’t have to.
Reference System.DirectoryServices, then call:
System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain()
Throws an ActiveDirectoryObjectNotFoundException
if the machine is not domain-joined.
The Domain object that’s returned contains the Name property you’re looking for.