/// <summary> /// /// </summary> public override void Start() { Guid hidGuid = new Guid(); HidD_GetHidGuid(ref hidGuid); UacBuildDeviceList(0); for (IntPtr usbHandle = UacGetFirstDevice(); usbHandle != IntPtr.Zero; usbHandle = UacGetNextDevice(usbHandle)) { IntPtr hidHandle = UacGetHidDevice(usbHandle); if (hidHandle != IntPtr.Zero) { StringBuilder id = new StringBuilder(512); if (UacGetInstanceID(hidHandle, id, 512) != 0) { id.Replace('\\', '#'); string devPath = string.Format("\\\\?\\{0}#{{{1}}}", id.ToString().ToLower(), hidGuid); MicronasSndDev sndDev = new MicronasSndDev(usbHandle, hidHandle, devPath); if (sndDev.IsValid) { StartDevice(sndDev); } } } } PostStart(true); /** 20180626. #3609. Se anidan eventos y no se tratan bien en la cola. */ HwSupervisor.Enabled = true; }
/// <summary> /// /// </summary> public override void Init() { /* Lista de dispositivos ordenada según los va suministrando el SO */ Guid hidGuid = new Guid(); HidD_GetHidGuid(ref hidGuid); UacBuildDeviceList(0); for (IntPtr usbHandle = UacGetFirstDevice(); usbHandle != IntPtr.Zero; usbHandle = UacGetNextDevice(usbHandle)) { IntPtr hidHandle = UacGetHidDevice(usbHandle); if (hidHandle != IntPtr.Zero) { /*********************************************/ //StringBuilder name = new StringBuilder(512); //UacGetHardwareID(hidHandle, name, 512); //UacGetDirectShowDeviceName(hidHandle, name, 512); /*********************************************/ StringBuilder id = new StringBuilder(512); if (UacGetInstanceID(hidHandle, id, 512) != 0) { id.Replace('\\', '#'); string devPath = string.Format("\\\\?\\{0}#{{{1}}}", id.ToString().ToLower(), hidGuid); MicronasSndDev sndDev = new MicronasSndDev(usbHandle, hidHandle, devPath); if (sndDev.IsValid) { _SOSndDvcs.Add(sndDev.Type); } } } } }