public bool AddDriver(string infFullPath, bool install) { switch (this.Type) { case DriverStoreType.Online: return(SetupAPI.AddDriver(infFullPath, install)); case DriverStoreType.Offline: DismApi.Initialize(DismLogLevel.LogErrors); try { using (DismSession session = this.GetSession()) { DismApi.AddDriver(session, infFullPath, false); } } finally { DismApi.Shutdown(); } return(true); default: throw new NotSupportedException(); } }
public bool AddDriver(string infFullPath, bool install) { switch (this.Type) { case DriverStoreType.Online: try { SetupAPI.AddDriver(infFullPath, install); } catch (Win32Exception ex) { Trace.TraceError(ex.ToString()); return(false); } return(true); case DriverStoreType.Offline: try { DismApi.Initialize(DismLogLevel.LogErrors); try { using (DismSession session = this.GetSession()) { DismApi.AddDriver(session, infFullPath, false); } } finally { DismApi.Shutdown(); } } catch (DismRebootRequiredException) { return(true); } catch (DismException ex) { Trace.TraceError(ex.ToString()); return(false); } return(true); default: throw new NotSupportedException(); } }
public bool AddDriver(string infFullPath, bool install) { switch (this.Type) { case DriverStoreType.Online: try { SetupAPI.AddDriver(infFullPath, install); } catch (Win32Exception ex) { Trace.TraceError(ex.ToString()); return(false); } return(true); case DriverStoreType.Offline: throw new NotImplementedException(); default: throw new NotSupportedException(); } }