Click here to Skip to main content
15,907,326 members

Comments by mrDivan (Top 65 by date)

mrDivan 15-Jul-15 3:12am View    
You could try the following


public class WinDevices
{
static public List<deviceinfo> GetUSBDevices()
{
List<deviceinfo> devices = new List<deviceinfo>();

ManagementObjectCollection collection;
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity"))
collection = searcher.Get();


foreach (var device in collection)
{
var deviceInfo = new DeviceInfo();
deviceInfo.DeviceID = (string)device.GetPropertyValue("DeviceID");
deviceInfo.PNPDeviceID = (string)device.GetPropertyValue("PNPDeviceID");
deviceInfo.Description = (string)device.GetPropertyValue("Description");
deviceInfo.Name = (string)device.GetPropertyValue("Name");
deviceInfo.Caption = (string)device.GetPropertyValue("Caption");
deviceInfo.Service = (string)device.GetPropertyValue("Service");
devices.Add(deviceInfo);

// Other properties supported by Win32_PnPEntity
// See http://msdn.microsoft.com/en-us/library/aa394353%28v=vs.85%29.aspx
//var keys = new string[] {
// "Availability",
// "Caption",
// "ClassGuid",
// "CompatibleID[]",
// "ConfigManagerErrorCode",
// "ConfigManagerUserConfig",
// "CreationClassName",
// "Description",
// "DeviceID",
// "ErrorCleared",
// "ErrorDescription",
// "HardwareID[]",
// "InstallDate",
// "LastErrorCode",
// "Manufacturer",
// "Name",
// "PNPDeviceID",
// "PowerManagementCapabilities[]",
// "PowerManagementSupported",
// "Service",
// "Status",
// "StatusInfo",
// "SystemCreationClassName",
// "SystemName"
//};

}

collection.Dispose();
return devices;
}

public class DeviceInfo
{
public string Name { get; set; }
public string DeviceID { get; set; }
public string PNPDeviceID { get; set; }
public string Description { get; set; }
public string Caption { get; set; }
public string Service { get; set; }
}
}

Kind regards
Divan
mrDivan 15-Jul-15 3:07am View    
Good day

Please set the EnableViewState="true" on your control in your aspx page.

Kind regards
Divan
mrDivan 15-Jul-15 2:34am View    
Thank you for your reply.
I connect to a sql remote database from my machine and from the remote server.
mrDivan 2-Jul-15 3:41am View    
Anyone else have any ideas
mrDivan 1-Jul-15 7:11am View    
Hallo thank you for your quick response. Do you perhaps have an example of how to encrypt an attribute.

Kind regards
Divan