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
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
I would do a search on WMI, you should be able to get what you need using those classes or examples.
look in the Win32_DiskDrive class :-)
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
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
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
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);
}
}
}
}