AlexandruC
AlexandruC

Reputation: 3637

SetupDiCallClassInstaller returns false

I want to enable and disable a specific USB disk, I've found about this method:

 public static bool StateChange(bool Enable, int SelectedItem, IntPtr DevInfo)
        {
            bool result = false;
            SP_DEVINFO_DATA devInfoData = new SP_DEVINFO_DATA(); ;
            devInfoData.cbSize = Marshal.SizeOf(typeof(SP_DEVINFO_DATA));
            if (true == SetupDiEnumDeviceInfo(DevInfo, SelectedItem, devInfoData))
            {
                SP_PROPCHANGE_PARAMS pcp = new SP_PROPCHANGE_PARAMS(); ;
                pcp.ClassInstallHeader.cbSize = Marshal.SizeOf(typeof(SP_CLASSINSTALL_HEADER));
                pcp.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
                pcp.Scope = DICS_FLAG_GLOBAL;

                pcp.StateChange = (Enable ? DICS_ENABLE : DICS_DISABLE);
                if (true == SetupDiSetClassInstallParams(DevInfo, devInfoData, pcp, Marshal.SizeOf(pcp)))
                {
                    if (true == SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, DevInfo, devInfoData))
                    {
                        result = true;
                    }
                }
            }
            return result;
        }

But it fails when calling : SetupDiCallClassInstaller(DIF_PROPERTYCHANGE, DevInfo, devInfoData) (returns false)

Is it because I'm running windows 7 x64 ?

Upvotes: 1

Views: 3183

Answers (1)

mox
mox

Reputation: 6324

According to MSDN, .."for certain DIF requests, the caller must be a member of the Administrators group". Have you tested the credentials?

Upvotes: 1

Related Questions