From: snzhai@hotmail.com
Sent: Thursday, August 16, 2001 2:33 AM
To: NT Developers Interest List
Subject: [ntdev] dynamically install/uninstall filter driver for USB
device


Hello All,

Currently, I am writing a application to dynamically install/uninstall my 
lower filter driver to USB device. The methods I am using to install and 
load filter driver is as follows:
(1) Add the LowerFilters registry value to the devnode registry;
(2) Stop and restart device with the following statements:

    SP_PROPCHANGE_PARAMS params;
    SP_DEVINSTALL_PARAMS installParams;
    memset(&params, 0, sizeof(SP_PROPCHANGE_PARAMS));
    params.ClassInstallHeader.cbSize = sizeof(SP_CLASSINSTALL_HEADER);
    params.ClassInstallHeader.InstallFunction = DIF_PROPERTYCHANGE;
    params.StateChange = DICS_PROPCHANGE;
    params.Scope       = DICS_FLAG_CONFIGSPECIFIC;
    params.HwProfile   = 0; // current profile

    // prepare for the call to SetupDiCallClassInstaller 
    if (!SetupDiSetClassInstallParams( DeviceInfoSet,
                                       DeviceInfoData,
                                       (PSP_CLASSINSTALL_HEADER) &params,
                                       sizeof(SP_PROPCHANGE_PARAMS)
                                       ))
    {
	dwError = GetLastError();
        return (FALSE); // Couldn't set the install parameters!
    }

    // stop and restart the device
    if (!SetupDiCallClassInstaller( DIF_PROPERTYCHANGE,
                                    DeviceInfoSet,
                                    DeviceInfoData 
									))
       
    {
	dwError = GetLastError();
        return (FALSE); // Call to class installer (DICS_PROPCHANGE) 
failed!
    }

My current problem is that the above method works fine in Win2k, but in 
Win98/Me, after successfully return from calling to 
SetupDiCallClassInstaller(), it will need to wait a long time (over 20 
seconds) before the device takes effective. BTW, if at this point I call a 
MessageBox to pop up a message box, then the device will take effective 
immediately. I cannot imagine what is the reason. Could anyone help me 
explain what is the reason and what is wrong in my method.

I have also tried to call SetupDiCallClassInstaller two times first with 
parameter DICS_STOP and second with DICS_RESTART. It works fine in Win2k, 
but failed in Win98/Me.

I have tested the USBVerify (provided in NTDDK), it can work in both Win2k 
and Win98/Me and the time to install filter driver in Win98/Me is much 
shorter than that what I did in my application.

Could anyone give me in detail how USBVerify works to install filter driver 
in Win98/Me? I don't know if it is possible to provide me some source codes 
to illustrate the detailed procedures.

I will appreciate your BIG help!

Best Regards,
snzhai

---
You are currently subscribed to ntdev as: GlennEverhart@FirstUSA.com
To unsubscribe send a blank email to leave-ntdev-247T@lists.osr.com