翻遍了platform sdk,以下几个问题还是没解决。。1 使用setup api做安装程序,怎么能得到安装进度?使用默认的回调函数SetupDefaultQueueCallback回弹出一个对话框,感觉不好。而且也只有拷贝文件的进度,有没有办法得到总的安装进度呢?如果不能,怎么得到单个操作的进度,比如拷贝文件,修改注册表,注册dlls等的单个进度。。2 在inf文件中使用registerdlls指示符是否只能在win2k以上的版本才能用?(SetupInstallFromInfSection函数使用SPINST_REGSVR标志),sdk上说在2k上才能用,有没有人在98下试过的?3 修改注册表操作有没有回调函数通知?(SetupInstallFromInfSection函数使用SPINST_REGISTRY标志),sdk上好象没有这个通知。。

解决方案 »

  1.   

    Updating Registry Information
    After the queue has successfully committed, you will need to update registry information for the product you are installing. It is recommended that you wait until all necessary file copy operations have been successfully completed before altering registry information.
    One way to update the registry is to call SetupInstallFromInfSection with the SPINST_INIFILES, SPINST_REGISTRY, or SPINST_INI2REG flags specified. These flags can be combined in one call to SetupInstallFromInfSection.The following example uses SPINST_ALL^SPINST_FILES to indicate that the function should process all of the listed operations except file operations. Since only INI, registry, and file operations are listed in the Install section, this is a shorthand method of specifying the function should process all INI and registry operations.The following example shows how to install registry information using the SetupInstallFromINFSection function.Test = SetupInstallFromINFSection (
         NULL,                     \\Window to own any dialog boxes
                                   \\  created 
         MyInf,                    \\INF file containing the section 
         MySection,                \\the section to install
         SPINST_ALL ^ SPINST_FILES,\\which installation operations 
                                   \\  to process
         NULL,                     \\the relative root key
         NULL,                    \\the source root path
         0,                        \\copy style
         NULL,                     \\Message handler routine
         NULL,                     \\Context
         NULL,                     \\Device info set
         NULL                      \\device info data
    );
    In the example, OwnerWindow is NULL because only file operations generate dialog boxes, and thus a parent window is not needed. MyInf is the INF file containing the section to process. The parameter, MySection, specifies the section to be installed. The combined flags, SPINST_ALL ^ SPINST_FILES, specify which installation operations to process, in this case, all operations except file operations. The source root path is specified as "A:\".Since no copy operations are being processed, the CopyFlags, MsgHandler, Context, DeviceInfoSet, and DeviceInfoData parameters are not specified.
      

  2.   

    Default Queue Callback Routine
    Included with the setup functions is a default callback routine, SetupDefaultQueueCallback, that you can use to process notifications returned by SetupCommitFileQueue.
    The following sections discuss the format of the default queue callback routine, using the default queue callback routine with SetupCommitFileQueue, and how to create a filter callback routine that builds on the functionality provided by the default queue callback routine.
    About the Default Queue Callback Routine 
    Using the Default Queue Callback Routine 
    Default Queue Callback Routine Reference
      

  3.   

    关于进度显示,我测试过通过传入SetupInitDefaultQueueCallbackEx的第2个参数
    HWND AlternateProgressWindow和第3个参数来实现,结果,收到的消息中两个参数不是1,0就是0,0。
      

  4.   

    顶一下,目前拷贝文件的进度条解决了。。可通过SetupInitDefaultQueueCallbackEx来实现。
      

  5.   

    xiaohyy(醉大饿极) :
    能不能发一份解决以后的代码呢?[email protected]
      

  6.   

    to 楼上:你需要什么代码?如果是setup api的,msdn上有一个列子。。我只解决了拷贝文件进度的问题,其实这个进度只是一个不准确的值,好象没有其他办法了。
    连2k中setup api的原代码都翻出来了,还是没有办法,估计是不行了。m_pContext = SetupInitDefaultQueueCallbackEx(m_hOwner,hProgress,uiProgreassMsg,0,NULL);BEGIN_MSG_MAP(CSetupPage)
    MESSAGE_HANDLER(WM_UG_PROGREASS, OnProgress)
    END_MSG_MAP()
    LRESULT OnProgress(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
    {
    if( 0 == wParam )
    m_wndProgress.SetRange(0,(UINT)lParam);
    else if( 1 == wParam && 0 == lParam )
    m_wndProgress.SetPos( m_wndProgress.GetPos()+1 ); return S_OK;
    }
    wparam为0,表示lparam参数为需要拷贝文件的数量,wparam为1表示目前已拷贝了一个文件。这个进度是以文件个数做为range,每拷贝一个递增1个tick