Hi Firends yesterday i have play with Win32_Operating System class and i have found out using this task i can intract with my computer operating system.. I had dig into that and for sample here i am going to write code to find out your computer last bootup time
VB.NET Code
Public Sub Lastbootuptime()
Dim strComputer As String = "." ' Local computer
Dim objWMIDateTime As Object = CreateObject("WbemScripting.SWbemDateTime")
Dim objWMI As Object = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim colOS As Object = objWMI.InstancesOf("Win32_OperatingSystem")
For Each objOS In colOS
objWMIDateTime.Value = objOS.LastBootUpTime
MessageBox.Show("Last Boot Up Time: " & objWMIDateTime.GetVarDate)
Next
End Sub
Abhishek Hingu at:
http://www.indianic.com/
Monday, December 1, 2008
Wednesday, September 3, 2008
Generate Counter Image runtime
Tuesday, September 2, 2008
Validate String max length using Reguler Expression in C#
class Program
{
static void Main(string[] args)
{
if (Regex.IsMatch("[Input String]","^.{4,20}$" ))
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
Console.ReadLine();
}
}
{
static void Main(string[] args)
{
if (Regex.IsMatch("[Input String]","^.{4,20}$" ))
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
Console.ReadLine();
}
}
Wednesday, May 21, 2008
Universal Contdown timer + javascript
//Javascript to create Universal Countdown timer
function GetCount(){
dateFuture = new Date(document.getElementById('servertime').value); // Get server datetime to find time difference between local time and server time as per GMT
var d=new Date();
var localTime = d.getTime();
var localOffset = d.getTimezoneOffset() * 60000;
var utc = localTime + localOffset;
var offset = document.getElementById('offset').value;
var london = utc + (3600000*offset);
dateNow = new Date(london); //grab current date
amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
delete dateNow;
// time is already past
if(amount < 0){
document.getElementById('countbox').innerHTML="Now!";
}
// date is still good
else{
days=0;hours=0;mins=0;secs=0;out="";
amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
days=Math.floor(amount/86400);//days
amount=amount%86400;
hours=Math.floor(amount/3600);//hours
amount=amount%3600;
mins=Math.floor(amount/60);//minutes
amount=amount%60;
secs=Math.floor(amount);//seconds
if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}
out += secs +" seconds";
document.getElementById('countbox').innerHTML=out;
setTimeout("GetCount()", 1000);
}
}
//
//
//
function GetCount(){
dateFuture = new Date(document.getElementById('servertime').value); // Get server datetime to find time difference between local time and server time as per GMT
var d=new Date();
var localTime = d.getTime();
var localOffset = d.getTimezoneOffset() * 60000;
var utc = localTime + localOffset;
var offset = document.getElementById('offset').value;
var london = utc + (3600000*offset);
dateNow = new Date(london); //grab current date
amount = dateFuture.getTime() - dateNow.getTime(); //calc milliseconds between dates
delete dateNow;
// time is already past
if(amount < 0){
document.getElementById('countbox').innerHTML="Now!";
}
// date is still good
else{
days=0;hours=0;mins=0;secs=0;out="";
amount = Math.floor(amount/1000);//kill the "milliseconds" so just secs
days=Math.floor(amount/86400);//days
amount=amount%86400;
hours=Math.floor(amount/3600);//hours
amount=amount%3600;
mins=Math.floor(amount/60);//minutes
amount=amount%60;
secs=Math.floor(amount);//seconds
if(days != 0){out += days +" day"+((days!=1)?"s":"")+", ";}
if(days != 0 || hours != 0){out += hours +" hour"+((hours!=1)?"s":"")+", ";}
if(days != 0 || hours != 0 || mins != 0){out += mins +" minute"+((mins!=1)?"s":"")+", ";}
out += secs +" seconds";
document.getElementById('countbox').innerHTML=out;
setTimeout("GetCount()", 1000);
}
}
//
//
//
Subscribe to:
Posts (Atom)