Get Hardware Detail from Drive Letter

Hi all,

May i know how we can get hardware detail from a Drive Letter by using VC++ .Net?

Hardware Detail are like GUID, Hardware ID, Friendly Name and etc.

Regards

[189 byte] By [bxchan] at [2007-12-26]
# 1

I would do a search on WMI, you should be able to get what you need using those classes or examples.

GlennWilson at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 3

Wow... This is a great tools for developer.

Thank you admedilyas...

For an VC++.Net and J# developer .... this is not quite a good news, because this tool only generate for C# and VB.

Does Microsoft was forget the people who are working in VC++ and J#?

This tool will be best if it can cover all the language in Visual Studio (C#, VC++, VB and J#).......

Regards

bxchan

bxchan at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 4

Hi,

I try the WMI Code Creator but I still unable to know the relationship between Drive Letter and and it's hardware Info.

For eg, I able to know the DriveLetter(A:, C:, D:, E:) from Win32_LogicalDisk under DeviceID, and Hardware Detail (Friendly Name) from Win32_DiskDrive under Model.

How to Link both DriveLetter to HardwareDetail?

For eg.

C: is WDC WD200BB-75DEA0
D: is SONY NWWM MEM AAD2 USB Device

Regards.

bxchan

bxchan at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 5

in .NET 2.0 you can use the DriveInfo class to get a list of all drives installed or mapped on the system. Example:

DriveInfo[] theDrives = DriveInfo.GetDrives();

foreach(DriveInfo curDrive in theDrives)

{

MessageBox.Show(curDrive.Name);

}

away from this....and into WMI. I see DiskDrive class has the DeviceID and the LogicalDisk has the Name. So somehow you need to perform some similar SQL Join statement or something.

Ill see what I can try

ahmedilyas at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 6

Hope to listen good news from you.... :)

bxchan at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Base Class Library...
# 7

Sorry, i able to get the device from Win32_DeviceChangeEvent,

what kind of information i able get from and how i can determine what kind of message(arrival or removed) message?

here is the code that i generate.

using System;
using System.Management;
using System.Windows.Forms;

namespace WMISample
{
public class WMIReceiveEvent
{
public static void Main()
{
try
{
WqlEventQuery query = new WqlEventQuery(
"SELECT * FROM Win32_DeviceChangeEvent");

ManagementEventWatcher watcher = new ManagementEventWatcher(query);
Console.WriteLine("Waiting for an event...");

ManagementBaseObject eventObj = watcher.WaitForNextEvent();

Console.WriteLine("{0} event occurred.", eventObj["__CLASS"]);

// Cancel the event subscription
watcher.Stop();
return;
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to receive an event: " + err.Message);
}
}
}
}

bxchan at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified