Exemple #1
0
            /// <summary>
            /// Changes the properties of a device by calling the <see cref="SetupDiSetClassInstallParams"/> and <see cref="SetupDiChangeState"/> functions
            /// </summary>
            /// <param name="installFunction">The function to call</param>
            /// <param name="stateChange">The new state</param>
            /// <param name="scope">Scope for the change</param>
            /// <param name="hardwareProfile">HardwareProfile to use</param>
            public void ChangeProperty(DIF installFunction, DICS stateChange, DICS_FLAGS scope, uint hardwareProfile)
            {
                var p = new SP_PROPCHANGE_PARAMS();

                p.ClassInstallHeader.cbSize          = (uint)Marshal.SizeOf(p.ClassInstallHeader);
                p.ClassInstallHeader.InstallFunction = installFunction;
                p.StateChange = stateChange;
                p.Scope       = scope;
                p.HwProfile   = hardwareProfile;
                var deviceInfo = this.deviceInfo;
                { //Set parameters
                    if (!SetupDiSetClassInstallParams(Handle, ref deviceInfo, ref p, (uint)Marshal.SizeOf(p)))
                    {
                        throw new Win32ErrorException();
                    }
                    KERNEL32.CheckLastError();
                }
                { //Run change
                    if (!SetupDiChangeState(Handle, ref deviceInfo))
                    {
                        throw new Win32ErrorException();
                    }
                    KERNEL32.CheckLastError();
                }
                //if (!SetupDiCallClassInstaller(installFunction, m_Handle, ref deviceInfo))
            }
Exemple #2
0
 public static extern bool SetupDiSetClassInstallParams(Handle deviceInfoSet, [In] ref SP_DEVINFO_DATA deviceInfoData, [In] ref SP_PROPCHANGE_PARAMS classInstallParams, uint classInstallParamsSize);