Recently, many people have been asked about this item, which may be used for dynamic software upgrades. Here we will record it.
There are two methods. One is to run the corresponding cab file directly through shellexecuteex. One is to call CreateProcess and use wceload to call this cab. You can use either method. The following code is written in the test program:
Case id_help_install1: <br/>{< br/> // specify an action for the application to perform, flags and other parameters <br/> shellexecuteinfo; <br/> info. cbsize = sizeof (Info); <br/> info. fmask = see_mask_flag_no_ui; <br/> info. hwnd = NULL; <br/> info. lpverb = _ T ("open"); <br/> info. lpfile = _ T ("// program files // runcab // samplecab1.cab"); <br/> info. lpparameters = _ T (""); info. lpdirectory = _ T (""); <br/> info. nshow = sw_show; <br/> info. hinstapp = g_hinst; <br/> // call to perform an action <br/> shellexecuteex (& info); <br/> break; <br/>}< br/> case id_help_install2: <br/>{< br/> lptstr szcmdline = _ tcsdup (<br/> text ("/" // program files // runcab // samplecab2.cab /"")); <br/> CreateProcess (_ T ("wceload.exe"), szcmdline, null, null, false, inherit_caller_priority, null); <br/> break; <br/>}
This test program has made different attempts with different menuitems, and both of the above implementations can work. Note that the preceding CreateProcess must enclose the space path parameters in quotation marks.