Getting a memory corruption error on this:
Here's the documentation I'm trying to translate to C#:
C++(msdn)
http://msdn.microsoft.com/en-us/library/dd877207%28v=vs.85%29.aspx[
^]
NET_API_STATUS NetEnumerateComputerNames(
__in_opt LPCWSTR Server,
__in NET_COMPUTER_NAME_TYPE NameType,
__in ULONG Reserved,
__out PDWORD EntryCount,
__out LPWSTR **ComputerNames
);
C#
[DllImport("Netapi32.dll", SetLastError = true)]
public static extern int NetEnumerateComputerNames(
[MarshalAs(UnmanagedType.LPWStr)]
string server_name,
NET_COMPUTER_NAME_TYPE name_type,
ulong reserved,
out int entry_count,
out IntPtr computer_names
);
public static void GetRemoteSystemInformation(string host, ref string computer_name, ref string system_os)
{
computer_name = "";
system_os = "Unknown";
int entry_count;
IntPtr p_computer_names;
var ret = PInvoke.NetEnumerateComputerNames(host, (int)NET_COMPUTER_NAME_TYPE.NET_PRIMARY_COMPUTER_NAME, 0, out entry_count, out p_computer_names);
if (PInvoke.ERROR_SUCCESS == ret)
{
}
}
[edit]Code blocks, link linkified - OriginalGriff[/edit]