You can easily learn you mobile phone's IMEI number
by pressing star square 06 square
*#06#
Web development blog, including simple php, mysql, c#, html, js, nginx tips and tutorials.
16 December 2008
11 December 2008
C# Read Harddisk Serial Number WMI ManagementClass Win32_LogicalDisk
With the Win32_LogicalDisk Management path we can reach the local disk information.
Even you can read harddisk serial number,
size, partitions, free space and so on.
Now let's read the serial number of a harddisk in C# with ManagementClass WMI.
C# Read Harddisk Serial Number WMI ManagementClass.
Even you can read harddisk serial number,
size, partitions, free space and so on.
Now let's read the serial number of a harddisk in C# with ManagementClass WMI.
public static string HardDiskID()This static function will simple give us the volume serial numbers.
{
ManagementClass partionsClass = new ManagementClass("Win32_LogicalDisk");
ManagementObjectCollection partions = partionsClass.GetInstances();
string hdd = string.Empty;
foreach (ManagementObject partion in partions)
{
hdd = Convert.ToString(partion["VolumeSerialNumber"]);
if (hdd != string.Empty)
return hdd;
}
return hdd;
}
C# Read Harddisk Serial Number WMI ManagementClass.
28 November 2008
C# Textbox Auto Scroll To End ScrollToCaret Scrolling Textbox
Many of my sample C# codes,
I use textbox to write the results.
When textbox is multiline property set to true, and when I insert text into it,
I want it to auto scroll to the last line.
Here is a simple way to auto scrolling textbox.
and ScrollToCaret() function will auto scroll textbox to the end.
I use textbox to write the results.
When textbox is multiline property set to true, and when I insert text into it,
I want it to auto scroll to the last line.
Here is a simple way to auto scrolling textbox.
textbox1.SelectionStart = textbox1.Text.Length;Textbox SelectionStart will force the textbox control to select the last part of the text,
textbox1.ScrollToCaret();
textbox1.Refresh();
and ScrollToCaret() function will auto scroll textbox to the end.
C# The process cannot access the file because it is being used by another process
The process cannot access the file because it is being used by another process.
This error message is mostly comes up,
when you try to access a file which is opened by another process.
You may open an image file in one of your form in a picturebox with using ImageFromFile or something.
I mostly use memorystream to open an image.
After read it in byte[] write it into a stream and close it.
You can check whether a file is being used or not with a simple function.
Try to open a file with none share.
the file because it is being used by another process or not.
This error message is mostly comes up,
when you try to access a file which is opened by another process.
You may open an image file in one of your form in a picturebox with using ImageFromFile or something.
I mostly use memorystream to open an image.
After read it in byte[] write it into a stream and close it.
You can check whether a file is being used or not with a simple function.
Try to open a file with none share.
public bool IsFileUsedbyAnotherProcess(string filename)This function will return true if
{
try
{
File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.None);
}
catch (System.IO.IOException exp)
{
return true;
}
return false;
}
the file because it is being used by another process or not.
27 November 2008
C# Convert Hexadecimal to Binary String Conversion
There is no need to code tons of codes, loops, to convert hex to binary string. Convert.ToInt32 function is very useful for this purpose.
Let's convert the "A" character to binary format.
hex2binary("1a"); will return "11010";
hex2bianry("1a2c"); will return "1101000101100"; and so on.
Keep in mind that this hex to binary conversion style uses 32 bit integer number.
Let's convert the "A" character to binary format.
private string hex2binary(string hexvalue)When we call hex2binary("A"); it will return "1010" similar samples below;
{
string binaryval = "";
binaryval = Convert.ToString(Convert.ToInt32(hexvalue, 16), 2);
return binaryval;
}
hex2binary("1a"); will return "11010";
hex2bianry("1a2c"); will return "1101000101100"; and so on.
Keep in mind that this hex to binary conversion style uses 32 bit integer number.
25 November 2008
C# System Tray Minimize To Tray With NotifyIcon
Minimize application form to system tray is done
with the NotifyIcon control in Visual Studio.
NotifyIcon is in the System.Windows.Forms namespace.
Drag and drop a NotifyIcon control to your form.
To send your application form into the system tray,
we simple handle the form re-size event.
for our NotifyIcon control.
with the NotifyIcon control in Visual Studio.
NotifyIcon is in the System.Windows.Forms namespace.
Drag and drop a NotifyIcon control to your form.
To send your application form into the system tray,
we simple handle the form re-size event.
private void frmMain_Resize(object sender, EventArgs e)We can also set BallonTipIcon, BallonTipText, BallonTipTitle and Icon ,
{
if (FormWindowState.Minimized == this.WindowState)
{
mynotifyicon.Visible = true;
mynotifyicon.ShowBalloonTip(500);
this.Hide();
}
else if (FormWindowState.Normal == this.WindowState)
{
mynotifyicon.Visible = false;
}
}
for our NotifyIcon control.
mynotifyicon.BallonTipText = "My application still working...";
mynotifyicon.BallonTipTitle = "My Sample Application";
mynotifyicon.BallonTipIcon = ToolTipIcon.Info;
Favicon Generator How To Add Favicon to Your Website ico
Favicon size is 16x16 pixel. Favicons are very important feature, visitors may remember a website from its favicon.
Favicon is kind a symbol of a website.
How to add a favicon in your website html.
- Create a favicon online easily visit the link below and create your favicon online.
- Upload your favicon into your hosting site.
- Add the html tag below into your website, between head tags.
<link href="images/favicon.ico" rel="shortcut icon" />Done.
Other favicon generator resources:
http://www.favicon.cc/
http://www.degraeve.com/favicon/
http://www.favicon.co.uk/
Subscribe to:
Posts (Atom)