Getting Drive Volume Information in C#

It's very easy to getting Volume Information of our logical drives by using kernel32.dll

Just copy and paste the following code then run it...that's it. :)


using System.Runtime.InteropServices;


[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern bool GetVolumeInformation(string Volume,
StringBuilder VolumeName, uint VolumeNameSize,
out uint SerialNumber, out uint SerialNumberLength, out uint flags,
StringBuilder fs, uint fs_size);



private void Form1_Load(object sender, EventArgs e)
{
uint serialNum, serialNumLength, flags;
StringBuilder volumename = new StringBuilder(256);
StringBuilder fstype = new StringBuilder(256);
bool ok = false;
Cursor.Current = Cursors.WaitCursor;
foreach (string drives in Environment.GetLogicalDrives())
{
ok = GetVolumeInformation(drives, volumename, (uint)volumename.Capacity - 1, out serialNum,
out serialNumLength, out flags, fstype, (uint)fstype.Capacity - 1);
if (ok)
{
lblVolume.Text = lblVolume.Text + "\n Volume Information of " + drives + "\n";
lblVolume.Text = lblVolume.Text + "\nSerialNumber of is..... " + serialNum.ToString() + " \n";
if (volumename != null)
{
lblVolume.Text = lblVolume.Text + "VolumeName is..... " + volumename.ToString() + " \n";
}
if (fstype != null)
{
lblVolume.Text = lblVolume.Text + "FileType is..... " + fstype.ToString() + " \n";
}
}
ok = false;
}
Cursor.Current = Cursors.Default;
}


Hope this will helpful to you....

...S.VinothkumaR.

Nokia Secret Codes

*#06# for checking the IMEI (International Mobile Equipment Identity).

*#7780# reset to factory settings.

*#67705646# This will clear the LCD display(operator logo).

*#0000# To view software version.

*#2820# Bluetooth device address.

*#746025625# Sim clock allowed status.

#pw+1234567890+1# Shows if sim have restrictions.

*#92702689# - takes you to a secret menu where you may find some of the information below:

1. Displays Serial Number.

2. Displays the Month and Year of Manufacture

3. Displays (if there) the date where the phone was purchased (MMYY)

4. Displays the date of the last repair - if found (0000)

5. Shows life timer of phone (time passes since last start)

*#3370# - Enhanced Full Rate Codec (EFR) activation. Increase signal strength, better signal reception. It also help if u want to use GPRS and the service is not responding or too slow. Phone battery will drain faster though.

*#3370* - (EFR) deactivation. Phone will automatically restart. Increase battery life by 30% because phone receives less signal from network.

*#4720# - Half Rate Codec activation.

*#4720* - Half Rate Codec deactivation. The phone will automatically restart

If you forgot wallet code for Nokia S60 phone, use this code reset: *#7370925538#

Note, your data in the wallet will be erased. Phone will ask you the lock code. Default lock code is: 12345

Press *#3925538# to delete the contents and code of wallet.

Unlock service provider: Insert sim, turn phone on and press vol up(arrow keys) for 3 seconds, should say pin code. Press C,then press * message should flash, press * again and 04*pin*pin*pin# \

*#7328748263373738# resets security code.

Default security code is 12345

Change closed caller group (settings >security settings>user groups) to 00000 and ure phone will sound the message tone when you are near a radar speed trap. Setting it to 500 will cause your phone 2 set off security alarms at shop exits, gr8 for practical jokes! (works with some of the Nokia phones.) Press and hold "0" on the main screen to open wap browser.

...S.VinothkumaR.

Getting Disk Space using Management.

Hi all,


Here is I'm going to getting disk space and free space using WMI. For that we must add refference System.Management.dll. The below is coding ...check it out...


using System.Management;



RadioButton rdDrives;
private void Form1_Load(object sender, EventArgs e)
{
int i = 10;
foreach (string drives in Environment.GetLogicalDrives())
{
rdDrives = new RadioButton();
rdDrives.Text = drives;
rdDrives.Top = i+20;
this.Controls.Add(rdDrives);
Application.DoEvents();
i = i + 40;
}
}




private void btnGetDiskSpace_Click(object sender, EventArgs e)
{
string drive = "";
RadioButton rd;
//Control[] control = this.Controls.Find("RadioButton", false);
for (int j = 0; j < rd =" (RadioButton)this.Controls[j];" drive =" rd.Text;" drive =" drive.Substring(0,">




private void getSize(string drive)
{
ManagementObject diskSize = new ManagementObject("win32_logicaldisk.deviceid=\"" + drive + ":\"");
diskSize.Get();
lblSize.Text = "Disk Space in " + drive + " is :" + diskSize["Size"] + " bytes";
lblFreeSpace.Text = "Free space in " +drive +" is :" + diskSize["FreeSpace"] + " bytes";
}



OutPut:

That's it..
...S.VinothkumaR.

Getting Disk Information using DriveInfo in C#

Hi all,

I'm going to display all disk's information (VolumeLable, File System, Total Space, FreeSpace ...etc). Here is the code...check it out.


private void Form1_Load(object sender, EventArgs e)
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
Label lbl;
int i = 0;
foreach (DriveInfo d in allDrives)
{
lbl = new Label();
lbl.AutoSize = true;
lbl.Text = "Drive: " + d.Name.Substring(0,1) + "\n";
lbl.Text = lbl.Text + "FileType: " + d.DriveType + "\n";
if (d.IsReady)
{
lbl.Text = lbl.Text + "Volume label: " + d.VolumeLabel+ "\n";
lbl.Text = lbl.Text + "File system: " + d.DriveFormat + "\n";
lbl.Text = lbl.Text + "Available space to current user: " + d.AvailableFreeSpace + "bytes\n";
lbl.Text = lbl.Text + "Total available space: " + d.TotalFreeSpace + "\n";
lbl.Text = lbl.Text + "Total size of drive: " + d.TotalSize + "\n";
}
lbl.Top = i;
this.Controls.Add(lbl);
i = i + 110;
}
}


That's it...

...S.VinothkumaR.