public static bool GetJoinStatus(string computerName, ref NetworkJoinInformation info) { NetworkJoinInformation.Zero(ref info); computerName = computerName?.Trim(); if (string.IsNullOrEmpty(computerName)) { computerName = null; } IntPtr buffer = IntPtr.Zero; bool result; try { if (Win32.NetGetJoinInformation(computerName, ref buffer, ref info.Status) != 0) { return(false); } info.Domain = Marshal.PtrToStringUni(buffer); result = true; } catch { result = false; } finally { if (!buffer.IsZero()) { Win32.NetApiBufferFree(buffer); } } return(result); }
public static void Zero(ref NetworkJoinInformation info) { info.ComputerName = null; info.Domain = null; info.Status = NetworkJoinStatus.Unknown; }