SpringCard LibCs.Windows for .NET  18.10.10
A set of utilities for the Windows platform
SpringCard.LibCs.setupapi Class Reference

A class used to list / activate / deactivate and reset USB devices connected to the computer More...

Public Types

enum  DeviceAction { Disable, Reset, Enable }
 

Public Member Functions

 setupapi (IntPtr formHandle)
 
void HookFormToHardwareChange (IntPtr formHandle)
 Used to hook a window on hardware events More...
 
void DisconnectFromHardwareNotifications ()
 
bool ActivateDevice (string deviceName)
 Activate a device by its name More...
 
bool DeactivateDevice (string deviceName)
 Deactivate a device by its name More...
 
bool ResetDevice (string deviceName)
 Reset a device by its name More...
 
string [] GetDevicesList ()
 Returns a sorted list of all computer's devices More...
 

Detailed Description

A class used to list / activate / deactivate and reset USB devices connected to the computer

Example of use : setupapi usb = new setupapi(this.Handle);

To act on device's state: usb.ActivateDevice("name_of_the_device"); usb.DeactivateDevice("name_of_the_device"); usb.ResetDevice("name_of_the_device");

To list attached devices: foreach (string device in usb.GetDevicesList()) listBox1.Items.Add(device);

If you wish to be notified of devices status change, add this method to your app: protected override void WndProc(ref Message m) { if (m.WParam.ToInt32() == SpringCard.LibCs.Native.DBT_DEVNODES_CHANGED) { listBox1.Items.Clear(); string[] HardwareList = usb.GetDevicesList(); foreach (string s in HardwareList) { //if(s.ToLower().StartsWith("s")) listBox1.Items.Add(s); } label1.Text = listBox1.Items.Count.ToString() + " Devices Attached"; } break; } } base.WndProc(ref m); }

Member Function Documentation

◆ ActivateDevice()

bool SpringCard.LibCs.setupapi.ActivateDevice ( string  deviceName)

Activate a device by its name

Parameters
deviceName
Returns

◆ DeactivateDevice()

bool SpringCard.LibCs.setupapi.DeactivateDevice ( string  deviceName)

Deactivate a device by its name

Parameters
deviceName
Returns

◆ GetDevicesList()

string [] SpringCard.LibCs.setupapi.GetDevicesList ( )

Returns a sorted list of all computer's devices

Returns

◆ HookFormToHardwareChange()

void SpringCard.LibCs.setupapi.HookFormToHardwareChange ( IntPtr  formHandle)

Used to hook a window on hardware events

Parameters
form

◆ ResetDevice()

bool SpringCard.LibCs.setupapi.ResetDevice ( string  deviceName)

Reset a device by its name

Parameters
deviceName
Returns

The documentation for this class was generated from the following file: