For using WMI you need to add one DLL called System.Management.dll and add the namespace as
[sourcecode language="csharp"]
using System.Management
[/sourcecode]
Now Read the current Session of your system.
[sourcecode language="csharp"]
private void Read_Current_Session()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_ServerConnection");
foreach (ManagementObject queryObj in searcher.Get())
{
String RemoteIPAddress = queryObj["ComputerName"].ToString();
String RemoteUserName = queryObj["UserName"].ToString();
String RemoteActiveTime = queryObj["ActiveTime"].ToString();
}
}
catch (ManagementException e)
{
MessageBox.Show("WMI Error: " + e.Message);
}
}
[/sourcecode]
Few Years back I have developed one Open Source Tool (NetSpY) based on WMI and MQL. NetSpy (NetWorkSpy) is an Small Windows based application which will continiouly monitor your shared folder in the network and will generate the complete log of the accessing user activities. This can show you the immidiate popup message that who is accessing right now.
If you are interested please have a look over here,
Net Spy: Your Network Spy That Monitor Your System In Network And Generate Log For Any Changes
2 comments:
Can I have this project in Vb.net instead of C#
The code is available on Code Project. So you can download it and convert it on VB.NET. I have implemented it on C#
Post a Comment