QA: How to install a cab file on Pocket PC?

Victor Sharov (vic@softspb.com), October 26, 2001.

Question

I need to install a cab file that is already downloaded to my Pocket PC. How can I do it from my program?

Answer

Actually the only thing you need is just to start this file. Usually it is done by creating a new process via CreateProcess() as it is described in QA: How can I start another program and wait until it will be finished?. But in this case such approach does not work. To install a cab file you should call ShellExecuteEx function defined in "Shellapi.h" file and pass it a pointer to SHELLEXECUTEINFO structure that contains and receives information about the application being executed.

Note: Pocket PC doesn't support local file names. All file names should contain full path like _T("\\temp\\my.cab").

Source code

Here is a sample code that installs "my.cab" file located in "\temp" folder:

// Specify an action for the application to perform, flags and other parameters SHELLEXECUTEINFO info; info.cbSize = sizeof(info); info.fMask = SEE_MASK_FLAG_NO_UI; info.hwnd = NULL; info.lpVerb = _T("open"); info.lpFile = _T("\\Temp\\my.cab"); info.lpParameters = _T(""); info.lpDirectory = _T(""); info.nShow = SW_SHOW; info.hInstApp = AfxGetInstanceHandle(); // Call to perform an action ShellExecuteEx(&info);

Related resources: