ClassNetworkBrowser
Provides a mechanism for supplying a list of all PC names in the local network.
This collection of PC names is used in the ListNetworkComputers.frmMain form
This class makes use of a DllImport instruction. The purpose of which is as follows:
When a DllImport declaration is made in managed code (C#) it is a call to a legacy
unmanaged code module, normally a C++ Dynamic Link Library. These C++ Dll's are
usually part of the operating system API, or some other vendors API, and must be
used to carry out operations that are not native within the managed code C# framework.
This is fairly normal within the windows world. The only thing that needs careful consideration
is the construction of the correct type of STRUCTS, object pointers, and attribute markers,
which all contribute to making the link between managed (C#) and unmanaged code (C++)
more seamless
This class makes use of the following Dll calls
- Netapi32.dll : NetServerEnum, The NetServerEnum function lists all servers of the specified type that are visible in a domain. For example, an application can call NetServerEnum to list all domain controllers only or all SQL servers only. You can combine bit masks to list several types. For example, a value of 0x00000003 combines the bit masks for SV_TYPE_WORKSTATION (0x00000001) and SV_TYPE_SERVER (0x00000002).
- Netapi32.dll : NetApiBufferFree, The NetApiBufferFree function frees the memory that the NetApiBufferAllocate function allocates. Call NetApiBufferFree to free the memory that other network management functions return.
Definition
Namespace:ArtOfTest.WebAii.Network
Assembly:ArtOfTest.WebAii.dll
Syntax:
public sealed class NetworkBrowser
Inheritance: objectNetworkBrowser
Constructors
NetworkBrowser()
Constructor, simply creates a new NetworkBrowser object
Declaration
public NetworkBrowser()
Methods
NetApiBufferFree(IntPtr)
Netapi32.dll : The NetApiBufferFree function frees the memory that the NetApiBufferAllocate function allocates. Call NetApiBufferFree to free the memory that other network management functions return.
NetServerEnum(string, int, ref IntPtr, int, out int, out int, int, string, out int)
Netapi32.dll : The NetServerEnum function lists all servers of the specified type that are visible in a domain. For example, an application can call NetServerEnum to list all domain controllers only or all SQL servers only. You can combine bit masks to list several types. For example, a value of 0x00000003 combines the bit masks for SV_TYPE_WORKSTATION (0x00000001) and SV_TYPE_SERVER (0x00000002)
Declaration
public static extern int NetServerEnum(string ServerNane, int dwLevel, ref IntPtr pBuf, int dwPrefMaxLen, out int dwEntriesRead, out int dwTotalEntries, int dwServerType, string domain, out int dwResumeHandle)
Parameters
ServerNane
dwLevel
pBuf
dwPrefMaxLen
dwEntriesRead
dwTotalEntries
dwServerType
domain
dwResumeHandle
Returns
getNetworkComputers()
Uses the DllImport : NetServerEnum with all its required parameters (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt/netserverenum.asp for full details or method signature) to retrieve a list of domain SV_TYPE_WORKSTATION and SV_TYPE_SERVER PC's
Declaration
public ObservableCollection<string> getNetworkComputers()
Returns
Arraylist that represents all the SV_TYPE_WORKSTATION and SV_TYPE_SERVER PC's in the Domain