public static bool UninstallFilter(USBDevice Device, string DriverName, uint FilterType) { byte[] Property = null; uint PropertySize = 0; bool success; Property = USBUtils.GetDeviceRegistryProperty(Device.DevInfoSet, Device.DevInfoData, FilterType, ref PropertySize); if (Property == null || (Property[0] == 0)) { return(false); } else { if (!StrCmp(Property, PropertySize, DriverName)) { return(false); } else { /*Property = BytesFromString(DriverName); * PropertySize = (uint)Property.Length;*/ for (int i = 0; i < Property.Length; i++) { Property[i] = 0; } success = Native.SetupDiSetDeviceRegistryProperty(Device.DevInfoSet, ref Device.DevInfoData, FilterType, Property, PropertySize + 1); if (!success) { return(false); } } } UIntPtr hKey; OpenFilterParamsKey(Device, out hKey); if (!RegDeleteFilterParams(hKey)) { return(false); } return(true); }
public static bool IsFilterInstalled(USBDevice Device, string DriverName) { byte[] Property = null; uint PropertySize = 0; Property = USBUtils.GetDeviceRegistryProperty(Device.DevInfoSet, Device.DevInfoData, Native.SPDRP_LOWERFILTERS, ref PropertySize); if (Property != null && StrCmp(Property, PropertySize, DriverName)) { return(true); } else { return(false); } }
public static bool AnyFilterInstalled(List <USBDevice> Devices, string DriverName) { byte[] Property = null; bool FilterExists = false; uint PropertySize = 0; for (int i = 0; i < Devices.Count; i++) { Property = USBUtils.GetDeviceRegistryProperty(Devices[i].DevInfoSet, Devices[i].DevInfoData, Native.SPDRP_LOWERFILTERS, ref PropertySize); if (Property != null && StrCmp(Property, PropertySize, DriverName)) { FilterExists = true; break; } } return(FilterExists); }
public static bool InstallFilter(USBDevice Device, string DriverName, uint FilterType, uint Flags, string LogPath) { byte[] Property = null; uint PropertySize = 0; bool success; Property = USBUtils.GetDeviceRegistryProperty(Device.DevInfoSet, Device.DevInfoData, FilterType, ref PropertySize); if (Property == null || (Property[0] == 0)) { Property = BytesFromString(DriverName); PropertySize = (uint)Property.Length; int counter = 0; success = false; do { success = Native.SetupDiSetDeviceRegistryProperty(Device.DevInfoSet, ref Device.DevInfoData, FilterType, Property, PropertySize); counter++; }while ((!success) && (counter < 100)); if (!success) { return(false); } } else { if (StrCmp(Property, PropertySize, DriverName)) { //return false; // драйвер установлен } Property = BytesFromString(DriverName); PropertySize = (uint)Property.Length; success = Native.SetupDiSetDeviceRegistryProperty(Device.DevInfoSet, ref Device.DevInfoData, FilterType, Property, PropertySize); if (!success) { return(false); } } UIntPtr hKey; CreateFilterParamsKey(Device, out hKey); if (!RegWriteFilterParams(hKey, Flags, LogPath)) { Native.RegCloseKey(hKey); return(false); } Native.RegCloseKey(hKey); return(true); }