Getting USB drive name attached to windows ce device - c#

How to get name of usb drive attahced to my Windows ce device using c# or any or the native API.

You may be able to start with the C# DriveInfo class:
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" File type: {0}", d.DriveType);
if (d.IsReady == true)
{
Console.WriteLine(" Volume label: {0}", d.VolumeLabel);
Console.WriteLine(" File system: {0}", d.DriveFormat);
Console.WriteLine(
" Available space to current user:{0, 15} bytes",
d.AvailableFreeSpace);
Console.WriteLine(
" Total available space: {0, 15} bytes",
d.TotalFreeSpace);
Console.WriteLine(
" Total size of drive: {0, 15} bytes ",
d.TotalSize);
}
}
http://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx
or this may help:
Get List of connected USB Devices

The folder name is localized and can change from device to device. The way I do it is to query it from the same registry location the driver used for getting the name:
using(var key = Registry.LocalMachine.OpenSubKey(
#"\System\StorageManager\Profiles\USBHDProfile"))
{
USBDiskFolderName = key.GetValue("Folder").ToString();
}

Related

Is it possible to detect Gender using Google.Cloud.Vision

I found some code examples of detecting face:
var image = Image.FromFile(filePath);
var client = ImageAnnotatorClient.Create();
var response = client.DetectFaces(image);
int count = 1;
foreach (var faceAnnotation in response)
{
Console.WriteLine("Face {0}:", count++);
Console.WriteLine(" Joy: {0}", faceAnnotation.JoyLikelihood);
Console.WriteLine(" Anger: {0}", faceAnnotation.AngerLikelihood);
Console.WriteLine(" Sorrow: {0}", faceAnnotation.SorrowLikelihood);
Console.WriteLine(" Surprise: {0}", faceAnnotation.SurpriseLikelihood);
}
But I couldn't find 'IsMale' or 'Gender' property in faceAnnotation. How can I detect Gender using Google.Cloud.Vision?
I think AWS Rekognition could provide gender:
Q: What face attributes can I get from Amazon Rekognition?
Amazon Rekognition returns the following facial attributes for each face detected, along with a bounding box and confidence score for each attribute:
Gender
Smile
...
see: https://aws.amazon.com/rekognition/faqs/

What API to retrieve PC Disk Drive properties?

I need to check disk name and whether the "enable write caching on the device" is enabled or not. so far I tried api method DriveInfo.GetDrives , But it doesn't have any property or methods that can return information I am looking for.
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" Drive type: {0}", d.DriveType);
}
https://msdn.microsoft.com/en-us/library/system.io.driveinfo.getdrives(v=vs.110).aspx

How to get not initialised disk info C#

Is there a way to show data of not initialised HDDs? I need an app to show if there are any not initialised disks. Trying that:
DriveInfo[] disks = DriveInfo.GetDrives();
foreach(DriveInfo d in disks)
{
Console.WriteLine(d.Name + " " + d.DriveFormat);
}
But it shows only already formatted partitions

Display General tab information of property window of local disks in my computer

I need to access the type of disk and display it in the C# code. In this image "
Local Disk Image" the type is local disk.
In this image "Cluster Disk Image" the type of disk is cluster disk.
I have used driveInfo class to get the drive details. but I'm not able to display whether the drive is cluster or local disk. d.DriveType returns whether it is a removable or fixed types. and not the required local disk or cluster type.
My code is added below:
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" Drive type: {0}", d.DriveType);
if (d.IsReady == true)
{
Console.WriteLine(" Volume label: {0}", d.VolumeLabel);
Console.WriteLine(" File system: {0}", d.DriveFormat);
Console.WriteLine(
" Available space to current user:{0, 15} bytes",
d.AvailableFreeSpace);
Console.WriteLine(
" Total available space: {0, 15} bytes",
d.TotalFreeSpace);
Console.WriteLine(
" Total size of drive: {0, 15} bytes ",
d.TotalSize);
}
}
Is there any way to display the required info in C# code?
Thank you.

Enumerate audio input devices with WMI

I am using NAudio in my C# project, and I am looking for a way to enumerate audio input devices (microphone etc.), so i can get full name of them (not only the 31-characters long name that i can get from NAudio). I went through a few posts where people were enumerating audio output devices with WMI:
ManagementObjectSearcher objSearcher = new ManagementObjectSearcher(
"SELECT * FROM Win32_SoundDevice");
ManagementObjectCollection objCollection = objSearcher.Get();
Is it possible to enumerate input devices this way as well?
Thanks
To explore the WMI queries you can use a tool that generates the WMI code for you. You'll have plenty of WMI management classes to get the information from.
You can download the tool from Microsoft download center here
I wrote a blog post few years back about using WMI management services for administration. Hope this would give you a head start.
Here's snippet generated from the tool to get the list of installed sound cards on the device.
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_SoundDevice");
foreach (ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("List of sound cards installed");
Console.WriteLine("-----------------------------------");
Console.WriteLine("ProductName: {0}", queryObj["ProductName"]);
Console.WriteLine("Availability: {0}", queryObj["Availability"]);
Console.WriteLine("Caption: {0}", queryObj["Caption"]);
Console.WriteLine("ConfigManagerErrorCode: {0}", queryObj["ConfigManagerErrorCode"]);
Console.WriteLine("ConfigManagerUserConfig: {0}", queryObj["ConfigManagerUserConfig"]);
Console.WriteLine("CreationClassName: {0}", queryObj["CreationClassName"]);
Console.WriteLine("Description: {0}", queryObj["Description"]);
Console.WriteLine("DeviceID: {0}", queryObj["DeviceID"]);
Console.WriteLine("DMABufferSize: {0}", queryObj["DMABufferSize"]);
Console.WriteLine("ErrorCleared: {0}", queryObj["ErrorCleared"]);
Console.WriteLine("ErrorDescription: {0}", queryObj["ErrorDescription"]);
Console.WriteLine("InstallDate: {0}", queryObj["InstallDate"]);
Console.WriteLine("LastErrorCode: {0}", queryObj["LastErrorCode"]);
Console.WriteLine("Manufacturer: {0}", queryObj["Manufacturer"]);
Console.WriteLine("MPU401Address: {0}", queryObj["MPU401Address"]);
Console.WriteLine("Name: {0}", queryObj["Name"]);
Console.WriteLine("PNPDeviceID: {0}", queryObj["PNPDeviceID"]);
Console.WriteLine("PowerManagementSupported: {0}", queryObj["PowerManagementSupported"]);
Console.WriteLine("Status: {0}", queryObj["Status"]);
Console.WriteLine("StatusInfo: {0}", queryObj["StatusInfo"]);
Console.WriteLine("SystemCreationClassName: {0}", queryObj["SystemCreationClassName"]);
Console.WriteLine("SystemName: {0}", queryObj["SystemName"]);
}
}
catch (ManagementException e)
{
Console.WriteLine("An error occurred while querying for WMI data: " + e.Message);
}
}
Here's the output -
-----------------------------------
List of sound cards installed
-----------------------------------
ProductName: Realtek High Definition Audio
Availability:
Caption: Realtek High Definition Audio
ConfigManagerErrorCode: 0
ConfigManagerUserConfig: False
CreationClassName: Win32_SoundDevice
Description: Realtek High Definition Audio
DeviceID: HDAUDIO\FUNC_01&VEN_10EC&DEV_0662&SUBSYS_103C304A&REV_1001\4&3867FD9A&0&0001
DMABufferSize:
ErrorCleared:
ErrorDescription:
InstallDate:
LastErrorCode:
Manufacturer: Realtek
MPU401Address:
Name: Realtek High Definition Audio
PNPDeviceID: HDAUDIO\FUNC_01&VEN_10EC&DEV_0662&SUBSYS_103C304A&REV_1001\4&3867FD9A&0&0001
PowerManagementSupported: False
Status: OK
StatusInfo: 3
SystemCreationClassName: Win32_ComputerSystem
SystemName: PC-2322Q1
These are sound devices, so it includes input and output devices. Soundcards can have 0 or more outputs and 0 or more inputs.

Categories

Resources