Click here to Skip to main content
15,895,084 members
Home / Discussions / C#
   

C#

 
GeneralRe: Do stuff while button pressed down? Pin
la0113-Jun-10 17:46
la0113-Jun-10 17:46 
GeneralRe: Do stuff while button pressed down? Pin
Luc Pattyn13-Jun-10 18:02
sitebuilderLuc Pattyn13-Jun-10 18:02 
GeneralRe: Do stuff while button pressed down? Pin
la0115-Jun-10 13:33
la0115-Jun-10 13:33 
Questionneed help Pin
aaga513-Jun-10 9:56
aaga513-Jun-10 9:56 
AnswerRe: need help Pin
Luc Pattyn13-Jun-10 10:03
sitebuilderLuc Pattyn13-Jun-10 10:03 
AnswerRe: need help Pin
Lutosław13-Jun-10 12:26
Lutosław13-Jun-10 12:26 
AnswerRe: need help Pin
Abhinav S13-Jun-10 18:18
Abhinav S13-Jun-10 18:18 
QuestionProblem to use letters ( c: , d:) with the physical drive: Pin
muteb13-Jun-10 7:32
muteb13-Jun-10 7:32 
Hi
I'm trying to use the name of a logical drive (c: and dSmile | :) . I can't use them to get access to the physical drive in order to get the type, the model, the interface, the capacity, sectors and cylinders.

My code :

private void Form1_Load(object sender, EventArgs e)
{

ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk");
foreach (ManagementObject moDisk in mosDisks.Get())
{
comboBox2.Items.Add(moDisk["DeviceID"].ToString());
}

}




private void button4_Click_1(object sender, EventArgs e)
{
listView2.Items.Clear()
ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE DeviceID = '" + comboBox2.SelectedItem + "'");
foreach (ManagementObject moDisk in mosDisks.Get())
{

ListViewItem item = listView2.Items.Add("Type: " + moDisk["MediaType"].ToString());
ListViewItem item2 = listView2.Items.Add("Model: " + moDisk["Model"].ToString());
ListViewItem item3 = listView2.Items.Add("Interface: " + moDisk["InterfaceType"].ToString());
ListViewItem item4 = listView2.Items.Add("Capacity: " + moDisk["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + " GB)");
ListViewItem item5 = listView2.Items.Add("Partitions: " + moDisk["Partitions"].ToString());
ListViewItem item6 = listView2.Items.Add("Signature: " + moDisk["Signature"].ToString());
ListViewItem item7 = listView2.Items.Add("Cylinders: " + moDisk["TotalCylinders"].ToString());
ListViewItem item8 = listView2.Items.Add("Sectors: " + moDisk["TotalSectors"].ToString());
ListViewItem item9 = listView2.Items.Add("Heads: " + moDisk["TotalHeads"].ToString());
ListViewItem item10 = listView2.Items.Add("Tracks: " + moDisk["TotalTracks"].ToString());
ListViewItem item11 = listView2.Items.Add("Bytes per Sector: " + moDisk["BytesPerSector"].ToString());
ListViewItem item12 = listView2.Items.Add("Sectors per Track: " + moDisk["SectorsPerTrack"].ToString());
ListViewItem item13 = listView2.Items.Add("Tracks per Cylinder: " + moDisk["TracksPerCylinder"].ToString());
ListViewItem item14 = listView2.Items.Add("Description: " + moDisk["Description"].ToString());

}
}

I have used this code and it worked fine but I can't get the letters instead of the Model in the combox
private void Form1_Load(object sender, EventArgs e)
{

ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject moDisk in mosDisks.Get())
{
comboBox2.Items.Add(moDisk["Model"].ToString());


}

}

private void button4_Click_1(object sender, EventArgs e)
{
listView2.Items.Clear();

ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE Model = '" + comboBox2.SelectedItem + "'");
foreach (ManagementObject moDisk in mosDisks.Get())
{

ListViewItem item = listView2.Items.Add("Type: " + moDisk["MediaType"].ToString());
ListViewItem item2 = listView2.Items.Add("Model: " + moDisk["Model"].ToString());
ListViewItem item3 = listView2.Items.Add("Interface: " + moDisk["InterfaceType"].ToString());
ListViewItem item4 = listView2.Items.Add("Capacity: " + moDisk["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + " GB)");
ListViewItem item5 = listView2.Items.Add("Partitions: " + moDisk["Partitions"].ToString());
ListViewItem item6 = listView2.Items.Add("Signature: " + moDisk["Signature"].ToString());
ListViewItem item7 = listView2.Items.Add("Cylinders: " + moDisk["TotalCylinders"].ToString());
ListViewItem item8 = listView2.Items.Add("Sectors: " + moDisk["TotalSectors"].ToString());
ListViewItem item9 = listView2.Items.Add("Heads: " + moDisk["TotalHeads"].ToString());
ListViewItem item10 = listView2.Items.Add("Tracks: " + moDisk["TotalTracks"].ToString());
ListViewItem item11 = listView2.Items.Add("Bytes per Sector: " + moDisk["BytesPerSector"].ToString());
ListViewItem item12 = listView2.Items.Add("Sectors per Track: " + moDisk["SectorsPerTrack"].ToString());
ListViewItem item13 = listView2.Items.Add("Tracks per Cylinder: " + moDisk["TracksPerCylinder"].ToString());
ListViewItem item14 = listView2.Items.Add("Description: " + moDisk["Description"].ToString());

}
}
AnswerRe: Problem to use letters ( c: , d:) with the physical drive: Pin
Henry Minute13-Jun-10 8:14
Henry Minute13-Jun-10 8:14 
AnswerRe: Problem to use letters ( c: , d:) with the physical drive: Pin
Luc Pattyn13-Jun-10 8:21
sitebuilderLuc Pattyn13-Jun-10 8:21 
QuestionConnection string Pin
humayunlalzad13-Jun-10 3:01
humayunlalzad13-Jun-10 3:01 
AnswerRe: Connection string Pin
Abhinav S13-Jun-10 3:27
Abhinav S13-Jun-10 3:27 
GeneralRe: Connection string Pin
humayunlalzad13-Jun-10 3:51
humayunlalzad13-Jun-10 3:51 
Questioncrystal report and list<> Pin
reza assar12-Jun-10 21:39
reza assar12-Jun-10 21:39 
AnswerRe: crystal report and list Pin
Mycroft Holmes13-Jun-10 19:55
professionalMycroft Holmes13-Jun-10 19:55 
QuestionNeed to add 1 to a cache value Pin
Randall Hall12-Jun-10 18:07
Randall Hall12-Jun-10 18:07 
AnswerRe: Need to add 1 to a cache value Pin
Dan Mos12-Jun-10 18:21
Dan Mos12-Jun-10 18:21 
AnswerRe: Need to add 1 to a cache value Pin
Pete O'Hanlon13-Jun-10 4:44
mvePete O'Hanlon13-Jun-10 4:44 
QuestionTab Control with Exit Button Pin
royk12312-Jun-10 10:04
royk12312-Jun-10 10:04 
AnswerRe: Tab Control with Exit Button Pin
Dan Mos12-Jun-10 16:18
Dan Mos12-Jun-10 16:18 
GeneralRe: Tab Control with Exit Button Pin
royk12313-Jun-10 2:09
royk12313-Jun-10 2:09 
AnswerRe: Tab Control with Exit Button Pin
Amar Chaudhary12-Jun-10 17:09
Amar Chaudhary12-Jun-10 17:09 
QuestionSetting Datagridview combobox column value to null. Pin
priyamtheone12-Jun-10 6:14
priyamtheone12-Jun-10 6:14 
AnswerRe: Setting Datagridview combobox column value to null. Pin
Mycroft Holmes12-Jun-10 15:53
professionalMycroft Holmes12-Jun-10 15:53 
AnswerRe: Setting Datagridview combobox column value to null. [modified] Pin
priyamtheone14-Jun-10 5:43
priyamtheone14-Jun-10 5:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.