Singularity – The c# OS
In existing systems, safe code is an exotic newcomer who lives in a huge, luxurious home in an elegant, gated community with its own collection of services. Singularity, in contrast, has architected a single world in which everyone can be safe, with performance comparable to the unsafe world of existing systems.
Skype Wrapper for .NET Beta
The Skype Wrapper for .NET Starter Kit includes a managed code wrapper and three samples for the Skype API that enables developers to connect and consume Skype services inside .NET applications.
Vicarious Single
Here it is:
http://confidoboyd.blogspot.com/2006/04/vicarious-i-live-while-whole-world.html
and it’s pretty damn good
How to sort a ListView control by a column in Visual C#
From MS Knowledge base:
“This step-by-step article describes how to sort a ListView control by a column in your Visual C# application.”
Full Tutorial
C# Version 3.0 Specification
Describes proposed features of C# 3.0 that build on those of C# 2.0. (25 pages)
Full Article
How to Create a Notify Icon in c# without a form
Tested with .NET Framework 2.0 and Windows XP Professional SP2
This has been bugging me for weeks. I wanted a formless application with a Notify Icon but there didn’t seem to be way to do it. After searching for a solution, I figured I’d give it a try myself. As it turned out it was so easy it was ridiculous. All you have to do create a class that is inherits the iContainer interface. When you create the instance of the notify icon, pass a container object. After that, you can use at as if it was on a form. Make sure you set the Icon property as well. I also have this working with a context menu and I’m guess it will work with any control that requires an iContainer interface. When you create the project, go to the project properties and make sure Output Type is set to Windows Application. Here’s the code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing;
class ControlContainer : IContainer
{
ComponentCollection _components;
public ControlContainer()
{
_components = new ComponentCollection(new IComponent[] { });
}
public void Add(IComponent component)
{ }
public void Add(IComponent component, string Name)
{ }
public void Remove(IComponent component)
{ }
public ComponentCollection Components
{
get { return _components; }
}
public void Dispose()
{
_components = null;
}
}
class MainEntryClass
{
static void Main(string[] args)
{
SomeClass sc = new SomeClass();
Application.Run();
}
}
class SomeClass
{
ControlContainer container = new ControlContainer();
private System.Windows.Forms.NotifyIcon notifyIcon1;
public SomeClass()
{
this.notifyIcon1 = new NotifyIcon(container);
}
}
A FoxTrot with a binary math puzzle.
This FoxTrot cartoon has a binary math puzzle as an Easter Egg.
The binary numbers and their decimal equivalents:
01011001 89
01001111 79
01010101 85
01001110 78
01000101 69
01010010 82
01000100 68
Here’s the c# code to decifer it:
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“{0}{1}{2} {3}{4}{5}{6}”, new object[] { (char)89, (char)79, (char)85, (char)78, (char)69, (char)82, (char)68 });
Console.ReadLine();
}
}
}
Simple PC List from any Active Directory
Requirments:
- .NET FrameWork 2.0
- XP Professional SP2(I’ve only tested it on XP Pro SP2 but it should work on any system with the .NET framework 2.0 installed)
- Visual C# Express or better (Actually you only need the IDE for easy of coding. You can compile this class by saving it as a .CS file and then use .NET command lines see Building from the Command Line for details).
- Windows 2000 or higher Domain with Active Directory (tested on 2003 Domain)
- Administrative rights on the systems if you plan to copy files, modify the registry etc
I’ve found it invaluable to be able to iterate through all the PC’s on the domain and gather information, push files, set registry keys etc. I’ve installed new programs, gathered info on the state of the systems and the possibilities are endless. With Microsoft releasing the Express Edition of C# for free, it’s so much easier for network admins who want to do more on the their networks to get started with coding.
Years ago, when I started doing work over the network, the problem was the time it takes to time out if a system is not on or unreachable. I wrote a DLL in VB6 to ping but with 2.0 version of the .NET framework, they including pinging right into the System.Net.NetworkInformation namespace. This code will get a listing of all the systems on the domain no matter what domain it’s on and then ping each one. You don’t have to pass the domain name because it uses the property defaultnamingcontext which returns the name of the domain. From there it will ping each system and then you can write code to do whatver you need. I know there are more and better ways to do this but I wanted to keep it short and sweet. Also there is very little error checking so test, test ,test and add error some more try{} catch{} statements. It’s not my responsibility if you break anything on your network so be careful! Here’s the code. Sorry for the crappy formatting but it’s the best I could do. Copy the code and save it as with a .cs extension. SciTE is a great text editor to use for editing c# code.
//Create a blank project and add the .cs file to it
//Add References to System and System.DirectoryServices
using System;
using System.Collections;
using System.DirectoryServices;
using System.Net.NetworkInformation;
class SimplePCList
{
static void Main(string[] args)
{
Ping pinger = new Ping();
foreach (string pc in GetComputers())
{
try
{
PingReply reply = pinger.Send(pc, 20);
if (reply.Status == IPStatus.Success)
{
//Do what you need to like:
//Copy files to the system through the C$ share
//Get event log entries
//Create Registry Keys etc.Console.WriteLine(pc);
}
}
catch (Exception err)
{
Console.WriteLine(“Could not contact ” + pc + ” – ” + err.Message);
}
}
Console.ReadLine();
}
private static ArrayList GetComputers()
{
string rootdse =
GetObjectProperty(“LDAP://rootDSE”,”defaultnamingcontext”);
ArrayList pcs =
ADSearch(“LDAP://” + rootdse,”(objectclass=computer)”,”name”);
return pcs;
}
private static string GetObjectProperty(string ObjectPath, string ObjectProperty)
{
string prop = string.Empty;
DirectoryEntry entry = new DirectoryEntry(ObjectPath);
prop = entry.Properties[ObjectProperty].Value.ToString();
entry.Close();
entry.Dispose();
return prop;
}
public static ArrayList ADSearch(string ConnectString, string Filter, string Attrib)
{
ArrayList holding = new ArrayList();
DirectoryEntry entry = new DirectoryEntry(ConnectString);
DirectorySearcher DirSearcher = new DirectorySearcher(entry);
DirSearcher.Filter = (“(&” + Filter + “)”);
DirSearcher.PageSize = 100;
DirSearcher.SearchScope = SearchScope.Subtree;
foreach (SearchResult resEnt in DirSearcher.FindAll())
{
DirectoryEntry ent = resEnt.GetDirectoryEntry();
holding.Add(ent.Properties[Attrib].Value);
}
DirSearcher.Dispose();
entry.Close();
entry.Dispose();
return holding;
}
}
-
Recent
- Bush sings U2
- Inflatable spacecraft launches from Russia
- Darth Vader Calls the Emperor
- Why increase minimum wage when you can vote yourself a raise?
- Colbert in Action
- Slow motion beer cannon footage
- Give a dog a bone – over the internet
- Super Mario Brothers Themepark
- Search on Microsoft main page doesn’t work in Firefox
- Singularity – The c# OS
- Skype Wrapper for .NET Beta
- Ricky Manning Jr’s PR Machine
-
Links
-
Archives
- July 2006 (2)
- June 2006 (4)
- May 2006 (5)
- April 2006 (5)
- March 2006 (6)
- February 2006 (22)
- January 2006 (31)
-
Categories
-
RSS
Entries RSS
Comments RSS