|
Hello everyone,
In one of my project i have a requirement of getting OS Name,version information etc of local network.
Is anyone have any idea of getting Non-Windows OS infomation from Windows machine using c#,c++,or Win32 API.
Thanks in Advance.
Regards,
Jitendra Singh
|
|
|
|
|
A network does not have OS information, it's just a bunch of wires connecting a group of systems. And what exactly do you mean by "Non-Windows OS infomation from Windows machine"?
|
|
|
|
|
If you mean "I want to run software on my Windows machine to find out what OS all the other equipment on my network is running" then AFAIK you can't. Partly because some if it is unlikely to be a computer at all - printers, router, dedicated IoT devices and so forth; and mostly because security on most systems prevents it. If you advertise your OS, then you advertise your vulnerabilities - so it's kept within the machine for the most part to make it harder for attackers. You can guess by checking which ports are open - different OSes tend to open a different set of ports by default, so if they haven't been changed it might be indicative, but it won't be conclusive.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I mean i will provide a IP range that belongs to same local network.
For instance i give IP range 192.168.1.20 to 192.168.1.30
IP OS
192.168.1.20 Windows 7 x64 bit
192.168.1.21 Linux OS
192.168.1.22 Mac (Lion 10.7) x64 bit
192.168.1.23 Windows 7 x32 bit
I hope now the picture becomes more clearer.
Regards,
Jitendra Singh
|
|
|
|
|
And as I said: AFAIK, you can't do that.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
The only way that springs to mind depends on you having these machines running under Active Directory, with none Windows machines connecting to AD via Samba. If you have this, you can retrieve the details about the OS using AD services.
|
|
|
|
|
I've outsourced my enterprise level project to a freelancer and I got a quite good setup too. But now that contract has finished and the person has also moved to a new technology, in other words not willing to extend the contract. Now I'm looking into this code on myself. I do have a 2 3 years of background in C# and MVC. Below is a rough idea of my application architecture. Hopefully I've tried my best to abstract the architectural details of an enterprise level application. Please let me know if you need further brief on any of the questions.
All my Entities are defined as C# POCO classes as:
public class Product : BaseEntity
{
public int ProductId { get; set; }
public string ProductName { get; set; }
}
Now I've a IDbContext like as :
public interface IDbContext : IDisposable
{
IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity;
}
Base Entity is a Partial POCO class that each POCO entity is inheriting. Here is a class that implements this IDBContext as:
public class MyObjectContext : DbContext, IDbContext
{
public new IDbSet<TEntity> Set<TEntity>() where TEntity : BaseEntity
{
return base.Set<TEntity>();
}
}
Now I've defined a IDbContextFactory that is responsible for providing the DBContexts as :
public interface IDbContextFactory
{
Lazy<IDbContext> CreateDbContext();
}
The class implementing this IDBContextFactory interface is having below structure :
public class MyDbContextFactory : IDbContextFactory
{
public MyDbContextFactory(string dbConnectionString)
{
_dbConnectionString = Settings.DbConnectionString;
_dbContext = CreateDbContext();
}
public IDbContext CreateDbContext()
{
IDbContext dbContext = new IDbContext(() => CreateNewContext());
return dbContext;
}
private MyObjectContext CreateNewContext()
{
return new MyObjectContext (_dbConnectionString);
}
}
Here IRepo Pattern comes into role as:
public partial interface IRepository<T> where T : BaseEntity
{
T GetById(object id);
}
Now the Repository class implementing this Interface is as below :
public partial class EfRepository<T> : IRepository<T> where T : BaseEntity
{
private readonly Lazy<IDbContext> _dbContext;
private readonly IDbContextFactory _dbContextFactory;
private readonly Lazy<ObjectStateManager> _objectStateManager;
public EfRepository(IDbContextFactory dbContextFactory)
{
_dbContextFactory = dbContextFactory;
_dbContext= _dbContextFactory.CreateDbContext();
_objectStateManager= new Lazy<ObjectStateManager>(() => ((IObjectContextAdapter)_dbContext.Value).ObjectContext.ObjectStateManager);
}
public T GetById(object id)
{
return this.Entities.Find(id);
}
}
Till now we are done with the Infrastructure level setup for DB Access Management. Now the thing is to utilize this setup into Controllers(as I'm having directly accessing Repositories from Controllers) to as below :
public CountryController(Lazy<IRepository<Country>> countryRepository)
{
_countryRepository = countryRepository;
}
public Country GetCountryById(int id)
{
Country country = _countryRepository.Value.GetByIdNonProxiedAsync(id);
if (country != null)
return country;
else
return null;
}
Hopefully all above is clear. Now here are the some questions that I need to be answered :
1) Why we are having this layered flow like as:
IDBContext -> IDBContextFactory -> IRepository <T>
and then finally using this IRepository into Controllers for accessing Data objects. In other words why we are relying on Interfaces instead of actual Class Objects while implementing Constructor Injection for Country Controller ?
2) Is this the correct approach for a Enterprise level Application as it should be much scalable for future purpose. If there is any other then I would be glad to know about that ?
3) In Controller's constructor I've used Lazy>, so what's the purpose of this Lazy and is it beneficial actually If yes then in what way ?
modified 29-Jan-15 8:20am.
|
|
|
|
|
Run Run! Watch out for the flamethrower!
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Thanks mate. Please find it out yourself. I posted this question here by mistake. I appreciate your response.
|
|
|
|
|
Amy Dev wrote: public Country GetCountryById(int id)
{
Country country = _countryRepository.Value.GetByIdNonProxiedAsync(id);
if (country != null)
return country;
else
return null;
}
Not to answer your question, but this made me chuckle.
BTW you may want to ask the question in the QA or in the C# forum.
Your time will come, if you let it be right.
|
|
|
|
|
Thanks mate. Nice catch. I posted this question here by mistake. I appreciate your response and I've moved the question to ASP.NET Forum.
Just in case if you are interested then my answer is, I tried to abstract as much complexity I can hide from my code but I forgot this one here. Actually this method is coded as per parallel programming.
|
|
|
|
|
I would like to know which moron thought C++ was better than C. As for Java and C#!
Who needs multiple inheritance when you have copy and paste?
|
|
|
|
|
|
Thanks mate. Nice catch. I wish you continue your these kind of annoying replies.
|
|
|
|
|
|
Thanks mate. I posted this question here by mistake. I appreciate your response and I've moved the question to ASP.NET Forum.
Parallely I'm going through your referenced Link. Really thanks
|
|
|
|
|
Rule 1: Learn to read. At the top of the page, it says: "if you need specific help please ask your question here." and links to the QA forum: http://www.codeproject.com/Questions/ask.aspx[^]
Instead, you posted what looks like your homework in a non-question forum, because you couldn't be bothered to look properly.
Now, what makes you feel that I might want to bother myself and spend time answering your question, when you can't be bothered to ask in the right place?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Rule 2: You don't talk about CodeProject
How do you know so much about swallows? Well, you have to know these things when you're a king, you know.
modified 31-Aug-21 21:01pm.
|
|
|
|
|
And Nice revert back @Brent Jenkins.
Please let people think what else they want. It's upto them how they represent themselves to others as it describes their atticates which matters equal to technical strength.
|
|
|
|
|
We're a bit like Fight Club here and have similar rules:
http://www.urbandictionary.com/define.php?term=Rules+of+Fight+Club[^]
Of course, being programmers we're a lot more buff and better looking than those skinny, ugly guys in the film
How do you know so much about swallows? Well, you have to know these things when you're a king, you know.
modified 31-Aug-21 21:01pm.
|
|
|
|
|
Thanks mate. Nice catch. I posted this question here by mistake. I appreciate your response and I've moved the question to ASP.NET Forum.
My apologies for wasting your precious time.
|
|
|
|
|
0 - Well structured question! Well done for that!
1 - this forum is the Lounge where programming questions are not allowed.
Suggest you go to quick questions and ask this question again.
but as a really quick answer, you pass interfaces rather than objects so that you can pass any object that implements that interface - especially useful if you are unit testing, as you can pass fake objects that implement the interface.
PooperPig - Coming Soon
|
|
|
|
|
Thanks mate.I posted this question here by mistake. I appreciate your response and I've moved the question to ASP.NET Forum.
Regarding your answer, Thanks a lot for that. I got the point. I agree that was a stupid question but looking at someone else code in such a large application confused me. Thanks
|
|
|
|
|
There are no stupid questions - only stupid answers!
PooperPig - Coming Soon
|
|
|
|
|
There are many reasons for passing in an interface into a constructor. One reason is to be able to supply different implementations into the constructor, which is particularly useful when you want to unit test your code. Rather than having to pass in a concrete implementation, which might rely on things that are difficult to test, you can use a mocking tool to create a mock of the interface and pass this in. This makes it easy to do things like set up verifications.
|
|
|
|