To follow on what Peter said, this is the code I used (based
originally on posts in this group).
private bool installCabFile ()
{
try
{
ProcessInfo pi = new ProcessInfo();
if (CreateProcess ("\\Windows\\wceload.exe","/noaskdest /noui " +
downloadFileName, pi))
return false;
}
catch (Exception e)
{
Cursor.Current = Cursors.Default;
MessageBox.Show ("Problem installing Cab file " + e.ToString());
return true;
}
return false;
}
// CreateProcess PInvoke API
[DllImport("CoreDll.DLL", SetLastError=true)]
private extern static int CreateProcess
(
String imageName,
String cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
Int32 boolInheritHandles,
Int32 dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
byte [] si,
ProcessInfo pi
);
// GetLastError PInvoke API
[DllImport("CoreDll.dll")]
private extern static Int32 GetLastError();
public Int32 GetPInvokeError()
{
return GetLastError();
}
[DllImport("CoreDll.dll")]
private extern static Int32 WaitForSingleObject( IntPtr Handle, Int32
Wait);
public bool CreateProcess (String ExeName, String CmdLine, ProcessInfo
pi)
{
Int32 INFINITE;
unchecked {INFINITE = (int)0xFFFFFFFF;}
bool result = false;
if (pi == null)
pi = new ProcessInfo ();
byte [] si = new byte [128];
result = CreateProcess (ExeName, CmdLine, IntPtr.Zero, IntPtr.Zero, 0,
0, IntPtr.Zero, IntPtr.Zero, si, pi) != 0;
WaitForSingleObject (pi.hProcess,INFINITE);
return result;
}
public sealed class ProcessInfo
{
public IntPtr hProcess = IntPtr.Zero;
public IntPtr hThread = IntPtr.Zero;
public int dwProcessID = 0;
public int dwThreadID = 0;
}